![尝试 Python 更新后无法访问 CentOS 设置网络配置](https://linux22.com/image/38781/%E5%B0%9D%E8%AF%95%20Python%20%E6%9B%B4%E6%96%B0%E5%90%8E%E6%97%A0%E6%B3%95%E8%AE%BF%E9%97%AE%20CentOS%20%E8%AE%BE%E7%BD%AE%E7%BD%91%E7%BB%9C%E9%85%8D%E7%BD%AE.png)
我尝试在 CentOS 5.6 VM 上更新 Python,但随后遇到了一些问题。最初,yum
这是行不通的,但我已经解决了。
但是,现在我无法访问 下的网络配置部分setup
。
当我选择此选项时,我会在命令行中看到以下内容:
[root@crmpicco ~]# setup
Traceback (most recent call last):
File "/usr/sbin/system-config-network-tui", line 9, in <module>
from snack import *
ImportError: No module named snack
该文件的第 9 行如下:
from snack import *
我不熟悉 Python(我是 PHP 开发人员),所以我不确定该去哪里或如何修复它。
这是我安装的与Python相关的内容:
[root@crmpicco ~]# yum list installed | grep python
MySQL-python.x86_64 1.2.1-1 installed
audit-libs-python.x86_64 1.7.18-2.el5 installed
dbus-python.x86_64 0.70-9.el5_4 installed
gamin-python.x86_64 0.1.7-8.el5 installed
gnome-python2.x86_64 2.16.0-1.fc6 installed
gnome-python2-bonobo.x86_64 2.16.0-1.fc6 installed
gnome-python2-canvas.x86_64 2.16.0-1.fc6 installed
gnome-python2-gnomevfs.x86_64 2.16.0-1.fc6 installed
libselinux-python.x86_64 1.33.4-5.7.el5 installed
libxml2-python.x86_64 2.6.26-2.1.2.8.el5_5.1 installed
libxslt-python.x86_64 1.1.17-2.el5_2.2 installed
mod_python.x86_64 3.2.8-3.1 installed
python.x86_64 2.4.3-43.el5 installed
python-devel.i386 2.4.3-43.el5 installed
python-devel.x86_64 2.4.3-43.el5 installed
python-elementtree.x86_64 1.2.6-5 installed
python-iniparse.noarch 0.2.3-4.el5 installed
python-libs.x86_64 2.4.3-43.el5 installed
python-numeric.x86_64 23.7-2.2.2 installed
python-sqlite.x86_64 1.1.7-1.2.1 installed
python-urlgrabber.noarch 3.1.0-6.el5 installed
python26.x86_64 2.6.8-2.el5 installed
python26-libs.x86_64 2.6.8-2.el5 installed
rpm-python.x86_64 4.4.2.3-22.el5 installed
另外,我现在似乎使用的是 Python 2.6.8。
python --version
给我
Python 2.6.8
答案1
该错误抱怨缺少特定的 python 模块(库):
ImportError: No module named snack
在我的 Debian 上,snack.py
是由python-newt
软件包提供的。快速搜索CentOS 存储库建议在 CentOS 中调用它newt-python
。所以,尝试安装:
yum install newt-python
答案2
为了在 CentOS 5.6 安装上修复此问题,我执行了以下操作:
wget http://vault.centos.org/5.6/os/x86_64/CentOS/python-2.4.3-43.el5.x86_64.rpm
rpm -ivh --force python-2.4.3-43.el5.x86_64.rpm
答案3
我的建议是重新安装 2.6 版中的所有库,也许可以卸载python 2.4
,但我不确定那部分。
问题是现在您已经Python 2.6
安装并可能默认使用,而您几乎没有以下库python 2.6
(安装的库是python 2.4
:
libselinux-python.x86_64
libxml2-python.x86_64
libxslt-python.x86_64
python.x86_64
python-devel.i386
python-devel.x86_64
python-elementtree.x86_64
python-iniparse.noarch
python-libs.x86_64
python-numeric.x86_64
python-sqlite.x86_64
python-urlgrabber.noarch
我建议您要么删除python 2.6
(但这可能不是您想要的,要么安装所有缺少的库,如下所示python 2.6
:
yum install libselinux-python26.x86_64
yum install libxml2-python26.x86_64
yum install libxslt-python26.x86_64
yum install mod_python26.x86_64
yum install python26.x86_64
yum install python26-devel.i386
yum install python26-devel.x86_64
yum install python26-elementtree.x86_64
yum install python26-iniparse.noarch
yum install python26-libs.x86_64
yum install python26-numeric.x86_64
yum install python26-sqlite.x86_64
yum install python26-urlgrabber.noarch
我不能保证这样的安装一定会成功,但这就是精神。因为python 2.6
缺少 python 中的库(又名模块)才能正常工作。