Upgrading python2.6 to python3.6 under Linux - Tech

  1. Portal Home
  2. Tech

Upgrading python2.6 to python3.6 under Linux

# python -V
# cd /home/centos/Downloads
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
# tar xvf Python-3.6.1.tar.xz
# cd ./Python-3.6.1
# mkdir /usr/local/python3
# ./configure --prefix=/usr/local/python3    
# make && make install
zipimport.ZipImportError: can't decompress data; zlib not available

 

settle zipimport.ZipImportError: can't decompress data; zlib not available
1.Download Code: http://www.zlib.net/
2.unzip and install:

# cd /home/centos/Downloads/
# tar zxvf zlib-1.2.11.tar.gz 
# cd zlib-1.2.11
# ./configure
# make && make install

 

Reinstall python3:

# cd /home/centos/Downloads/Python-3.6.1
# ./configure -- prefix=/usr/local/python3
# make && make install
# mv /usr/bin/python /usr/bin/python_old
# ln -s /usr/local/python3/bin/python3 /usr/bin/python
# python
Python 3.6.1 (default, May 30 2017, 18:13:28) 
# yum search
File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax

 

Resolving yum is not available.

# vi /usr/bin/yum
#!/usr/bin/python    amend to    #!/usr/bin/python_old
# yum search