Centos 7 system python2.6 upgraded to 2.7.11

888u

Last update at :2024-02-06,Edit by888u

Today when I was tossing around with the pyone program, I found that the python version of centos chick was 2.6.6, which did not meet the requirements and needed to install 2.7. I looked it up on the Internet and found the tutorial. After a while, some problems appeared. The problem was finally solved. Let me share the solution process below.

1. Check the current python version

#python -V Python 2.6.6

2. Download Python-2.7.11

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz

3. Unzip and enter the directory

tar zxvf Python-2.7.11.tgz cdPython-2.7.11

4. Compile and install

./configure make all make install make clean makedisclean

5. View the installed version

/usr/local/bin/python2.7 -V Python 2.7.11

6. Establish a soft connection so that the system's default python points to python2.7

mv /usr/bin/python /usr/bin/python2.6.6 ln -s /usr/local/bin/python2.7 /usr/bin/python python -V Python 2.7.11

7. After solving the problem that the system Python soft link points to the Python2.7 version, because yum is not compatible with Python 2.7, yum cannot work properly. We need to specify the Python version of yum. Those who do not know VI editing commands can use Pagoda. File management to change.

#vi /usr/bin/yum

Change the header of the file

#!/usr/bin/python Change to #!/usr/bin/python2.6.6

8. Configure iBus

Use vim to open the following two files respectively, find the exec python line, change exec python to exec python2.6, save and exit. iBus returned to normal after restarting!

#vim /usr/bin/ibus-setup #vim /usr/libexec/ibus-ui-gtk

9. After completing the above tutorial, another error occurred when executing pip install -r requirements.txt.

Traceback (most recent call last): File "/usr/bin/pip", line 7, in from pip import main ImportError: No module named pip

Solution, find the installation path of pip in Python2.6:

find /usr -name pip

You can see the path:

/usr/lib/python2.6/site-packages/pip /usr/bin/pip

Just copy the pip file to python2.7/site-packages. The directory is as follows:

/usr/local/lib/python2.7/site-packages

Recommended site searches: domain name registration information query, Hong Kong host, Hong Kong server rental, cn domain name, registration-free jsp space, Taiwan proxy server, asp free space application, mainland China registration-free host, US anti-attack server, domain name space,

Centos 7 system python2.6 upgraded to 2.7.11

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码