前言
本文主要給大家介紹了因Python升級導致yum、pip報錯的解放方法,分享出來供大家參考學習,下面話不多說了,來一起看看詳細的介紹吧。
原因:
yum是Python寫的。服務器上Python版本過低,升級為2.7,而yum/pip未升級,導致在執行yum/pip時報這個錯誤。
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.10 (default, Sep 5 2017, 17:35:43) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
pip報錯:
Traceback (most recent call last): File "/usr/bin/pip2", line 5, in <module> from pkg_resources import load_entry_point ImportError: No module named pkg_resources
解決方案:
1、查看Python版本,執行:
which python
可以查看到存在兩個版本的Python。
2、查看yum文件,執行:
vim /usr/bin/yum
可以在文件的第一行,看到yum的Python引用。將原有的 #!/usr/bin/python 改為 #!/usr/bin/python2.6(老版本)
3、跳出再次執行yum,即可使用。
pip同理修改
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com