python 安装严重混乱,导致 Yum 无法在 Redhat 中运行

python 安装严重混乱,导致 Yum 无法在 Redhat 中运行

当我尝试安装 2.7.3 时,我愚蠢地 rm'd /usr/lib/python2.6,现在我的系统严重混乱。

我无法运行 yum、pip 或 easy_install 。

Yum 不起作用:

[root@bobby tmp]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.3 (default, Dec 28 2012, 15:18:47)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

easy_install 不起作用

[root@bobby tmp]# easy_install
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

pip 不起作用

[root@bobby tmp]# pip
Traceback (most recent call last):
  File "/usr/bin/pip-python", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

我再次尝试手动重新安装 setuptools(希望这可以安装 pkg_resources??)

[root@bobby tmp]# sh setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
  File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available

但是 Python 2.7.3 和 2.6.6 运行良好。

关于如何纠正这种情况有什么想法吗?

---------更新------------ rpm -V yum产生大量丢失的文件,我该如何重新安装这些文件?

[root@bobby python2.7]# rpm -V yum
missing     /usr/lib/python2.6/site-packages/rpmUtils
missing     /usr/lib/python2.6/site-packages/rpmUtils/__init__.py
missing     /usr/lib/python2.6/site-packages/rpmUtils/__init__.pyc
missing     /usr/lib/python2.6/site-packages/rpmUtils/__init__.pyo
missing     /usr/lib/python2.6/site-packages/rpmUtils/arch.py
missing     /usr/lib/python2.6/site-packages/rpmUtils/arch.pyc
missing     /usr/lib/python2.6/site-packages/rpmUtils/arch.pyo
missing     /usr/lib/python2.6/site-packages/rpmUtils/miscutils.py
missing     /usr/lib/python2.6/site-packages/rpmUtils/miscutils.pyc
missing     /usr/lib/python2.6/site-packages/rpmUtils/miscutils.pyo
missing     /usr/lib/python2.6/site-packages/rpmUtils/oldUtils.py
missing     /usr/lib/python2.6/site-packages/rpmUtils/oldUtils.pyc
missing     /usr/lib/python2.6/site-packages/rpmUtils/oldUtils.pyo
missing     /usr/lib/python2.6/site-packages/rpmUtils/transaction.py
missing     /usr/lib/python2.6/site-packages/rpmUtils/transaction.pyc
missing     /usr/lib/python2.6/site-packages/rpmUtils/transaction.pyo
missing     /usr/lib/python2.6/site-packages/rpmUtils/updates.py
missing     /usr/lib/python2.6/site-packages/rpmUtils/updates.pyc
missing     /usr/lib/python2.6/site-packages/rpmUtils/updates.pyo
missing     /usr/lib/python2.6/site-packages/yum
missing     /usr/lib/python2.6/site-packages/yum/Errors.py
missing     /usr/lib/python2.6/site-packages/yum/Errors.pyc
missing     /usr/lib/python2.6/site-packages/yum/Errors.pyo
missing     /usr/lib/python2.6/site-packages/yum/__init__.py
missing     /usr/lib/python2.6/site-packages/yum/__init__.pyc
missing     /usr/lib/python2.6/site-packages/yum/__init__.pyo
missing     /usr/lib/python2.6/site-packages/yum/callbacks.py
missing     /usr/lib/python2.6/site-packages/yum/callbacks.pyc
missing     /usr/lib/python2.6/site-packages/yum/callbacks.pyo
missing     /usr/lib/python2.6/site-packages/yum/comps.py
missing     /usr/lib/python2.6/site-packages/yum/comps.pyc
missing     /usr/lib/python2.6/site-packages/yum/comps.pyo
missing     /usr/lib/python2.6/site-packages/yum/config.py
missing     /usr/lib/python2.6/site-packages/yum/config.pyc
missing     /usr/lib/python2.6/site-packages/yum/config.pyo
missing     /usr/lib/python2.6/site-packages/yum/constants.py
missing     /usr/lib/python2.6/site-packages/yum/constants.pyc
missing     /usr/lib/python2.6/site-packages/yum/constants.pyo
missing     /usr/lib/python2.6/site-packages/yum/depsolve.py
missing     /usr/lib/python2.6/site-packages/yum/depsolve.pyc
missing     /usr/lib/python2.6/site-packages/yum/depsolve.pyo
missing     /usr/lib/python2.6/site-packages/yum/failover.py
missing     /usr/lib/python2.6/site-packages/yum/failover.pyc
missing     /usr/lib/python2.6/site-packages/yum/failover.pyo
missing     /usr/lib/python2.6/site-packages/yum/history.py
missing     /usr/lib/python2.6/site-packages/yum/history.pyc
missing     /usr/lib/python2.6/site-packages/yum/history.pyo
missing     /usr/lib/python2.6/site-packages/yum/i18n.py
missing     /usr/lib/python2.6/site-packages/yum/i18n.pyc
missing     /usr/lib/python2.6/site-packages/yum/i18n.pyo
missing     /usr/lib/python2.6/site-packages/yum/logginglevels.py
missing     /usr/lib/python2.6/site-packages/yum/logginglevels.pyc
missing     /usr/lib/python2.6/site-packages/yum/logginglevels.pyo
missing     /usr/lib/python2.6/site-packages/yum/mdparser.py
missing     /usr/lib/python2.6/site-packages/yum/mdparser.pyc
missing     /usr/lib/python2.6/site-packages/yum/mdparser.pyo
missing     /usr/lib/python2.6/site-packages/yum/metalink.py
missing     /usr/lib/python2.6/site-packages/yum/metalink.pyc
missing     /usr/lib/python2.6/site-packages/yum/metalink.pyo
missing     /usr/lib/python2.6/site-packages/yum/misc.py
missing     /usr/lib/python2.6/site-packages/yum/misc.pyc
missing     /usr/lib/python2.6/site-packages/yum/misc.pyo
missing     /usr/lib/python2.6/site-packages/yum/packageSack.py
missing     /usr/lib/python2.6/site-packages/yum/packageSack.pyc
missing     /usr/lib/python2.6/site-packages/yum/packageSack.pyo
missing     /usr/lib/python2.6/site-packages/yum/packages.py
missing     /usr/lib/python2.6/site-packages/yum/packages.pyc
missing     /usr/lib/python2.6/site-packages/yum/packages.pyo
missing     /usr/lib/python2.6/site-packages/yum/parser.py
missing     /usr/lib/python2.6/site-packages/yum/parser.pyc
missing     /usr/lib/python2.6/site-packages/yum/parser.pyo
missing     /usr/lib/python2.6/site-packages/yum/pgpmsg.py
missing     /usr/lib/python2.6/site-packages/yum/pgpmsg.pyc
missing     /usr/lib/python2.6/site-packages/yum/pgpmsg.pyo
missing     /usr/lib/python2.6/site-packages/yum/pkgtag_db.py
missing     /usr/lib/python2.6/site-packages/yum/pkgtag_db.pyc
missing     /usr/lib/python2.6/site-packages/yum/pkgtag_db.pyo
missing     /usr/lib/python2.6/site-packages/yum/plugins.py
missing     /usr/lib/python2.6/site-packages/yum/plugins.pyc
missing     /usr/lib/python2.6/site-packages/yum/plugins.pyo
missing     /usr/lib/python2.6/site-packages/yum/repoMDObject.py
missing     /usr/lib/python2.6/site-packages/yum/repoMDObject.pyc
missing     /usr/lib/python2.6/site-packages/yum/repoMDObject.pyo
missing     /usr/lib/python2.6/site-packages/yum/repos.py
missing     /usr/lib/python2.6/site-packages/yum/repos.pyc
missing     /usr/lib/python2.6/site-packages/yum/repos.pyo
missing     /usr/lib/python2.6/site-packages/yum/rpmsack.py
missing     /usr/lib/python2.6/site-packages/yum/rpmsack.pyc
missing     /usr/lib/python2.6/site-packages/yum/rpmsack.pyo
missing     /usr/lib/python2.6/site-packages/yum/rpmtrans.py
missing     /usr/lib/python2.6/site-packages/yum/rpmtrans.pyc
missing     /usr/lib/python2.6/site-packages/yum/rpmtrans.pyo
missing     /usr/lib/python2.6/site-packages/yum/sqlitesack.py
missing     /usr/lib/python2.6/site-packages/yum/sqlitesack.pyc
missing     /usr/lib/python2.6/site-packages/yum/sqlitesack.pyo
missing     /usr/lib/python2.6/site-packages/yum/sqlutils.py
missing     /usr/lib/python2.6/site-packages/yum/sqlutils.pyc
missing     /usr/lib/python2.6/site-packages/yum/sqlutils.pyo
missing     /usr/lib/python2.6/site-packages/yum/transactioninfo.py
missing     /usr/lib/python2.6/site-packages/yum/transactioninfo.pyc
missing     /usr/lib/python2.6/site-packages/yum/transactioninfo.pyo
missing     /usr/lib/python2.6/site-packages/yum/update_md.py
missing     /usr/lib/python2.6/site-packages/yum/update_md.pyc
missing     /usr/lib/python2.6/site-packages/yum/update_md.pyo
missing     /usr/lib/python2.6/site-packages/yum/yumRepo.py
missing     /usr/lib/python2.6/site-packages/yum/yumRepo.pyc
missing     /usr/lib/python2.6/site-packages/yum/yumRepo.pyo

- - - - 编辑 - - - - - - -

通过清除所有内容并重新安装,已“解决”。吸取教训!不要 rm -rf 你不明白的东西 :P

答案1

删除所有内容并重新安装。为 python2.6 和 2.7 重新安装 yum、easy_install、pip 太耗时了

答案2

pkg_resources 由 Distribute 或 setuptools 提供。正如 PyCon 2013 上宣布的那样,Distribute 和 setuptools 项目已重新合并。Distribute 现已弃用,您应该只使用新的当前 setuptools。试试这个:

curl -O https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
python ez_setup.py

原始解释在这里: https://stackoverflow.com/questions/1756721/what-is-causing-importerror-no-module-named-pkg-resources-after-upgrade-of-pyth

相关内容