centos系列(亲测有效):File “/usr/libexec/urlgrabber-ext-down“, line 28 except OSError, e:(yum安装东西时报错)

489 篇文章 ¥129.90 ¥299.90
文章讲述了在使用yum安装时遇到的错误,源于升级后的python软链接问题。解决办法是找到python2.7路径并修改urlgrabber-ext-down配置文件,指向旧版本Python。通过测试效果确认修复方法有效。

File "/usr/libexec/urlgrabber-ext-down", line 28 except OSError, e:(yum安装东西时报错)




一. File “/usr/libexec/urlgrabber-ext-down”, line 28 except OSError, e:

001、问题

在这里插入图片描述

002、问题原因

原因为升级python后新建了软连接指向了新版本,除非同时升级yum不然无法使用。需要手动更改报错文件指向python2后即可解决。

003、解决方法

找出python2.7的路径

whereis python

在这里插入图片描述

编辑报错的配置文件,vim /usr/libexec/urlgrabber-ext-down; 在

sudo yum install python2 Loaded plugins: fastestmirror, langpacks Determining fastest mirrors Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" * base: mirrors.bupt.edu.cn * extras: mirrors.bupt.edu.cn * updates: mirrors.aliyun.com http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. http://mirrors.bupt.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 403 - Forbidden Trying other mirror. To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. http://mirrors.njupt.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 403 - Forbidden Trying other mirror. http://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. http://mirrors.163.com/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. base | 3.6 kB 00:00 http://mirrors.ustc.edu.cn/centos/7.9.2009/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. http://mirrors.huaweicloud.com/centos/7.9.2009/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. extras | 2.9 kB 00:00 http://mirrors.huaweicloud.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. http://mirrors.ustc.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. updates | 2.9 kB 00:00 File "/usr/libexec/urlgrabber-ext-down", line 28 except OSError, e: ^ SyntaxError: invalid syntax File "/usr/libexec/urlgrabber-ext-down", line 28 except OSError, e: ^ SyntaxError: invalid syntax Exiting on user cancel
最新发布
08-24
<think>好的,我需要解决用户遇到的ModuleNotFoundError: No module named 'urlgrabber'错误。首先,我得回忆一下urlgrabber是什么。根据引用[5],用户可能在CentOS系统上升级了Python,导致yum出现问题,因为yum依赖于Python 2.6或2.7,而升级后可能路径或模块不兼容。 用户的问题是关于urlgrabber模块缺失。首先,我应该检查这个模块属于哪个软件包。在CentOS或RHEL系统中,urlgrabber通常包含在urlgrabber这个RPM包中,或者可能是yum的一个依赖。根据引用[5]中的例子,当用户升级Python后,yum可能无法找到正确的模块,因为yum仍然使用旧版本的Python路径。 可能的解决步骤包括:1. 确认Python版本是否正确配置,尤其是yum使用的Python路径是否指向系统自带的版本(如/usr/bin/python2.7)。如果用户将默认Python更改为新安装的版本,可能需要修改yum的脚本,使其指向原来的Python。例如,在yum脚本的第一行指定#!/usr/bin/python2.7。2. 安装urlgrabber包。可能需要使用yum或dnf来安装,但此yum本身可能无法运行,因此需要手动下载或修复Python环境。3. 检查是否有符号链接错误,确保模块路径正确。 另外,引用[3]中提到安装libffi-devel解决_ctypes的问题,这可能与模块编译有关,但当前问题更可能与环境路径有关。引用[5]提到将Python的路径恢复,比如将新安装的Python移到/usr/bin/python,而原来的备份为python2.6.6。如果用户升级Python后没有正确处理系统工具的依赖,可能导致此类问题。 总结解决步骤:首先恢复yum使用的Python解释器到系统原版本,确保yum能正常运行。然后,如果需要urlgrabber模块,使用系统包管理器安装。如果用户确实需要新版本Python,可能需要为yum单独配置使用旧版Python,避免冲突。</think>### 解决 Python 中 ModuleNotFoundError: No module named 'urlgrabber' 的方法 #### 问题原因 `urlgrabber` 是 `yum` 包管理工具的核心依赖模块,通常存在于 CentOS/RHEL 系统的默认 Python 2.x 环境中。错误可能由以下原因引起: 1. **Python 环境冲突**:手动升级或替换了系统默认的 Python 版本(如将 Python 3 设为默认),导致 `yum` 无法找到原 Python 2.x 的模块[^5]。 2. **模块缺失**:`urlgrabber` 未正确安装或路径配置错误。 --- #### 解决步骤 ##### 方法 1:恢复系统 Python 解释器路径(推荐) 1. **检查当前 Python 链接**: ```bash ls -l /usr/bin/python ``` 若输出指向 Python 3(如 `/usr/bin/python -> python3.7`),需修复为系统原 Python 2.x。 2. **恢复默认 Python 链接**: ```bash sudo mv /usr/bin/python /usr/bin/python3 # 备份当前链接 sudo ln -s /usr/bin/python2.7 /usr/bin/python # 重新链接到 Python 2.7 ``` 3. **验证 `yum` 功能**: ```bash yum update # 应不再报错 ``` ##### 方法 2:手动安装 `urlgrabber` 若需保留新 Python 版本为默认,需单独为系统工具配置 Python 2.x 环境: 1. **安装 `urlgrabber` 依赖**: ```bash sudo yum install -y urlgrabber # 使用 Python 2.x 的 yum 安装 ``` 2. **修改 `yum` 脚本的 Python 解释器**: ```bash sudo vi /usr/bin/yum ``` 将首行 `#!/usr/bin/python` 改为 `#!/usr/bin/python2.7`。 --- #### 验证修复 ```bash python -c "import urlgrabber" # 新 Python 环境可能仍缺失,但 yum 应正常 yum list installed | grep urlgrabber # 确认模块已安装 ``` ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坦笑&&life

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值