Centos6.7 comes with python upgrade to

Yesterday, due to work needs, the python that comes with centos6.7 was upgraded to 2.7. Among them, I have encountered some small twists and turns, let me record it, and you can make a reference when you encounter similar problems.

  1. First, you need to install readline-devel, because the system does not have readline related modules by default. If this module is not installed, garbled characters will appear when using the arrow keys and delete keys in the python shell.

Install readlin-devel, yum install readline-devel

  1. Then go to the official website to download the python2.7 source code package, I chose python2.7.8.

The next step is to unzip: tar xvf Python-2.7.8.tgz,

Then enter Python-2.7.8, cd Python-2.7.6

To compile:

. /configure --prefix=/usr/local/python2.7

make

make install

  1. Create a link to make the system default python become python2.7

ln -fs /usr/local/python2.7/bin/python2.7 /usr/bin/python

  1. Check the python version

python –V

  1. Modify yum configuration (otherwise yum cannot run normally)

vi /usr/bin/yum

Modify the #!/usr/bin/python in the first line to the original python version address #!/usr/bin/python2.6

At this point, python has been upgraded. If you have used easy_install or pip to install a third-party module before, you will find that easy_install or pip cannot be used after the upgrade.

The reason is: Although you have upgraded Python to version 2.7, pip is still the original version and is still in the original python site-package. So you can copy all the things in the original /usr/lib/python2.6/site-packages to the python2.7 directory (/usr/local/python2.7/lib/python2.7/site-packages/)

cp -pr /usr/lib/python2.6/site-packages/* /usr/local/python2.7/lib/python2.7/site-packages/

Ok, now you can happily install third-party modules with pip.

yum install pip: yum install python-pip

In addition, when I installed the pillow module, I found that the python official website download was too slow, so I provided several python domestic mirror sites (fast flying).

Alibaba Cloud is the fastest https://mirrors.aliyun.com/pypi/simple/

University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/

Douban https://pypi.douban.com/simple/

××× http://pypi.mirrors.opencas.cn/simple/

Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/

Using the mirror source is very simple, just specify it with -i, for example: easy_install -i https://pypi.douban.com/simple/ pillow

Pip is the same. pip install pillow -i https://mirrors.aliyun.com/pypi/simple/

To specify the global installation source, add the following content to vim $HOME/.pip/pip.conf (if there is no such file, create one manually)

[ global]
timeout =6000  
index-url = https://mirrors.aliyun.com/pypi/simple/

Pip installs multiple third-party packages at once (pip install -r requirements.txt) Write the name of the package to be installed in requirements.txt

pip list (view installed packages)

pip wheel package name (package)

If you want to install the specified version of the python package, just add == the specified version after the package. Such as pip install matplotlib==2.1.1 -i https://mirrors.aliyun.com/pypi/simple/

Note that after upgrading pip to 9.0.1, the error pkg_resources.DistributionNotFound: pip==7.1.0 is reported. The solution is as follows:

vim /usr/bin/pip Change the version behind pip== to the installed pip version

Recommended Posts

Centos6.7 comes with python upgrade to
Centos 6.4 python 2.6 upgrade to 2.7
Centos default python2.6 upgrade to
CentOS upgrade python2 to pyth
CentOS7 upgrade python3
CentOS6.5 upgrade kernel to 3.10.28
CentOS comes with Python deleted && YUM error repair
How to upgrade CentOS7 to CentOS8 (detailed steps)
CentOS + Python3.6+
How to install Python 3.8 on CentOS 8
How to install Python on CentOS 8
Centos 7.5 python3.6
CentOS7 repairs python to save yum
How to make a globe with Python
Centos python3 compile installation and compile gcc upgrade
R&D: How To Install Python 3 on CentOS 7
How to process excel table with python
How to get started quickly with Python
How to monitor CentOS 7 server with Prometheus
Centos6 install Python2.7.13
Ubuntu16 upgrade Python3
Centos7 install Python 3.6.
CentOS install Python 3.6
Python - centos6 installation
Centos7 install Python2.7
Centos install Python3
Centos7 upgrade kernel
CentOS6.8 install python2.7
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
Introduction to Python
ubuntu16.04 upgrade python2
How to upgrade all Python libraries on Ubuntu 18.04
How to convert web pages to PDF with Python
How to play happily with Python3 on Ubuntu
Where is the IDE that comes with Python
Python how to delete rows with empty columns
How to read and write files with Python
How to deal with python file reading failure
python requests.get with header
CentOS7.5-1804 system kernel upgrade
Getting started with Python(9)
How to upgrade to Ubuntu 20.04
Centos source installation Python3
Getting started with Python(8)
How to configure FTP server with Vsftpd on CentOS 8
Getting started with Python(4)
Web Scraping with Python
Centos7 comes with rsync, which is briefly recorded today.
Getting started with Python (2)
Centos kernel version upgrade
Getting started with python-1
Getting started with Python(14)
Getting started with Python(7)
Getting started with Python(17)
Getting started with Python(15)
How to configure FTP server with Vsftpd on CentOS 8
Getting started with Python(10)
Getting started with Python(11)
CentOS 5 to CentOS 5.8 YUM source
Getting started with Python(6)
Getting started with Python(3)