CentOS 7.4安装EPEL仓库后yum功能异常求助
Hey, let's work through this issue you're stuck on. The key clue in your error logs is this line: 无法解析metalink链接https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=armhfp — notice it's trying to fetch the armhfp architecture repo, but CentOS 7.4 Core is almost certainly running on x86_64. That's exactly why you're hitting the "No repomd file" error. Here's how to fix it step by step:
1. Verify Your System's Actual Architecture
First, confirm what architecture your system is using to be sure:
uname -m
You should see x86_64 as the output. If that's the case, the $basearch variable in yum is resolving incorrectly, which is pulling the wrong repo path.
2. Fix the EPEL Repo Configuration
Edit the epel.repo file to force the correct architecture and disable the problematic metalink:
# Replace all instances of $basearch with your actual architecture (x86_64 here) sudo sed -i 's/$basearch/x86_64/g' /etc/yum.repos.d/epel.repo # Comment out the metalink line that's causing the error sudo sed -i 's/^metalink/#metalink/g' /etc/yum.repos.d/epel.repo # Uncomment the baseurl line to use the direct, valid repo path sudo sed -i 's/^#baseurl/baseurl/g' /etc/yum.repos.d/epel.repo
If you are actually running on ARM (unlikely for CentOS 7.4 Core), replace x86_64 with your correct architecture value instead.
3. Clear Yum Cache and Rebuild
Wipe out the old, invalid cache and generate a fresh one with the corrected config:
sudo yum clean all sudo yum makecache
4. Install Python 3.6
Now you should be able to install Python 3.6 without any repo errors:
sudo yum -y install python36
Alternative: Use a Domestic EPEL Mirror (More Stable)
If the above doesn't resolve things, switching to a domestic mirror (like Alibaba Cloud's) can avoid metalink parsing issues entirely:
- Backup your old repo files first:
sudo mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak sudo mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.bak
- Create a new
epel.repowith Alibaba's mirror:
sudo tee /etc/yum.repos.d/epel.repo <<EOF [epel] name=Extra Packages for Enterprise Linux 7 - \$basearch baseurl=https://mirrors.aliyun.com/epel/7/\$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 EOF
- Clean cache and install Python 3.6:
sudo yum clean all sudo yum makecache sudo yum -y install python36
Why Your Previous Attempts Didn't Work
When you tried toggling baseurl/metalink comments before, you didn't address the root problem: the $basearch variable was resolving to armhfp instead of your actual system architecture. By hardcoding the correct architecture or using a mirror that handles variable resolution reliably, you eliminate the metalink parsing error entirely.
内容的提问来源于stack exchange,提问作者Jan Hamara




