CentOS 7 python2.7.5 升级到 python 2.7.18 步骤以及问题
-
python升级
yum install gcc openssl-devel bzip2-devel cd /usr/src wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz tar xzf Python-2.7.18.tgz cd Python-2.7.18 ./configure --enable-optimizations make altinstall /usr/local/bin/python2.7 -V # Python 2.7.18 mv /usr/bin/python /usr/bin/python2.7.5 ln -s /usr/local/bin/python2.7 /usr/bin/python
pip安装
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py python get-pip.py
各种错误
No module named yum
更新完后,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.18 (default, Jul 20 2021, 22:48:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
修改:/usr/bin/yum
#!/usr/bin/python2.7.5
No module named urlgrabber.grabber
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Traceback (most recent call last): File "/usr/libexec/urlgrabber-ext-down", line 22, in <module> from urlgrabber.grabber import \ ImportError: No module named urlgrabber.grabber
修改:vi /usr/libexec/urlgrabber-ext-down
同上