在Centos 8上安装Python 3时返回“无法同步存储库”BaseOS“的缓存”

js81xvg6  于 2022-11-07  发布在  Python
关注(0)|答案(2)|浏览(130)

我使用的是CentOS 8。我正在尝试安装Python 3。命令:sudo dnf install python3。错误:
无法同步存储库“BaseOS”的缓存
我该如何解决这个问题?

vcudknz3

vcudknz31#

Centos对$releasever的值做了一些有趣的事情,他们使用的是完整版本8.0.1905,而不是8。当新版本8.1.1911发布时,他们存档了旧版本。如果您安装旧媒体或使用旧的vagrant box,这可能会导致以下问题:

[vagrant@localhost ~]$ sudo dnf upgrade
CentOS-8.0 - AppStream                                                                                                                                                                                        1.6 kB/s |  38  B     00:00    
CentOS-8.0 - Base                                                                                                                                                                                             748  B/s |  38  B     00:00    
CentOS-8.0 - Extras                                                                                                                                                                                           126  B/s |  38  B     00:00    
Extra Packages for Enterprise Linux Modular 8.0 - x86_64                                                                                                                                                       53 kB/s |  63 kB     00:01    
Extra Packages for Enterprise Linux 8.0 - x86_64                                                                                                                                                               80 kB/s |  63 kB     00:00    
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Failed to synchronize cache for repo 'BaseOS', ignoring this repo.
Failed to synchronize cache for repo 'extras', ignoring this repo.
Failed to synchronize cache for repo 'epel-modular', ignoring this repo.
Failed to synchronize cache for repo 'epel', ignoring this repo.
Dependencies resolved.
Nothing to do.
Complete!

此问题的修复方法是在dnf命令行上使用--releasever选项指定Centos版本,如下所示:

[vagrant@localhost ~]$ sudo dnf upgrade --releasever=8
CentOS-8 - AppStream                                                                                                                                                                                          164 kB/s | 7.0 MB     00:43    
CentOS-8 - Base                                                                                                                                                                                               313 kB/s | 2.2 MB     00:07    
CentOS-8 - Extras                                                                                                                                                                                             5.1 kB/s | 5.5 kB     00:01    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                                                                                         63 kB/s | 116 kB     00:01    
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                                                                5.9 MB/s | 6.5 MB     00:01    
Dependencies resolved.
vktxenjb

vktxenjb2#

在mirror.centos.orgvault.centos.org相应的存储库文件中,将baseurl从www.example.com更改为www.example.com,如下所示:
/etc/yum.存储库d/

相关问题