centos6 python version upgrade to python3.5

1, from the Python official website to obtain Python3 packet, switching to the directory / usr / local / src

 

wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz

 

Second, using the following command decompress command:

 

-d Python - xz 3.5 . 1 . tar .xz // will extract the files xz 
tar -xf Python - 3.5 . 1 . tar

 

Third, create directory --python3.5 under / usr / local path, the install directory of Step 4

 

1  mkdir / usr / local / python3. 5

 

Fourth, compile and install

 

1 $cd /usr/local/src/Python-3.5.1
2 #./configure --prefix=/usr/local/python3.5
3 #make all
4 #make install
5 #make clean
6 #make distclean

 

Fifth, check whether the installation was successful

 

1 / usr / local / python3. 5 / bin / python3. 5 - V
 2 Python 3.5 . one

 

Sixth, the viewing environment variable PATH in order to find the default when you start python, python in / usr / bin is in this case the Python2.6.6

 

1 $echo $PATH
2 /usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/gordon/bin

 

Seven, modify soft link, pointing to python3.5 start python

1, backup python

 

mv   / usr / bin / Python / usr / bin / python2. 6.6  // backup centos default python 2.6.6 of

2, modified soft connection

 

1 ln -s /usr/local/python3.5/bin/python3 /usr/bin/python

 

3. Verify whether the default start python3.5

 

1 $ for python - the V
 2   the Python 3.5 . one

 

Eight, In this case, the system will not be used yum command, because it relies original python2.6.6 yum modify the first line of:

 

1 vim /usr/bin/yum
2 #!/usr/bin/python2.6.6

 

You may also need to modify the first line in this route

 vim / usr / libexec / urlgrabber-ext-down to #! / usr / bin / python into a #! / usr / bin / python2.6.6

Error encountered:

After upgrading the python, you pip need to reinstall command. Pip installation path or else be wrong. (Because the time prior to installation of python may --prefix parameter set), the source is preferably mounted manner reinstall (http://www.cnblogs.com/hoojjack/p/8672612.html)

1, pip error

 

1 [root@docker Python-3.5.1]# pip
2 Traceback (most recent call last):
3   File "/usr/bin/pip", line 7, in <module>
4     from pip._internal import main
5 ImportError: No module named 'pip._internal'

 

Description pip mapping file is not installed correctly when you install python3.5, installed by default pip3.5

Backup of the original system default: mv / usr / bin / pip / usr / bin / pip_bak, pip3.5 create a soft link ln -s /usr/local/bin/pip3.5 / usr / bin / pip

1 [root@docker local]# mv /usr/bin/pip /usr/bin/pip_bak
2 [root@docker local]# ln -s /usr/local/bin/pip3.5 /usr/bin/pip
3 [root@docker local]# pip
4 
5 Usage:   
6   pip <command> [options]

2、You are using pip version 7.1.2, however version 10.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' command.

 

1 [root@docker local]# pip install --upgrade pip

 

3, after the upgrade, the issue of hash arrow keys, backspace Backspace etc. appear in interactive mode.

 

yum install readline  readline-devel

 

If you find that the system has been readline library, just in / lib64 / directory, thus, made a soft to / usr / lib / and / usr / lib64 /

 

1 ln -s  /lib64/libreadline.so.6 /usr/lib/
2 
3 ln -s  /lib64/libreadline.so.6 /usr/lib64/
4 
5 ln -s  /lib64/libreadline.so.6.0 /usr/lib/
6 7 ln -s /lib64/libreadline.so.6.0 /usr/lib64/

 

Recompile install it again python35, the problem can be resolved.

 

Guess you like

Origin www.cnblogs.com/new-journey/p/11359407.html