天天看點

Python3.5更新3.7PreparationBuilding The Soft Link

Ubuntu16.04 Python3.5更新Python3.7

  • Preparation
    • 1.Download python3.7
    • 2. Decompress
    • 3. Compile and Install
  • Building The Soft Link
    • 1. Delete the Old Soft Link
    • 2. Building New Soft Link
    • 3. Test
    • 4. Issues

Preparation

Ubuntu16.04系統自帶兩個python版本,一個是python2.7,很快就不會維護了,另一個是python3.5,但是目前很多最新庫,尤其是深度學習相關的庫要求python3.6以上,是以要更新。

1.Download python3.7

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

other versions:https://www.python.org/downloads/source/

2. Decompress

Enter the download directory

tar zxvf Python-3.7.3.tgz
cd Python-3.7.3
           

3. Compile and Install

./configure --with-ssl
make
sudo make install
           

attention: the option --with-ssl in order to avoid install error when using pip install

Building The Soft Link

1. Delete the Old Soft Link

sudo rm -rf /usr/bin/python3
sudo rm -fr /usr/bin/pip3
           

2. Building New Soft Link

Before building the new soft link, you can use “whereis python3.7” command to locate the installation directory.

sudo ln -s /usr/local/bin/python3.7 /usr/bin/python3
sudo ln -s /usr/local/bin/pip3.7 /usr/bin/pip
           

3. Test

python3 -V
pip3 -V
           

4. Issues

Terminal will can’t be opened due to it depend on python3.5, now we modify the python3 point to python3.5, so the sw depend on python3.5 will has this issues. Here is a solution:

cd /usr/bin
sudo gedit gnome-terminal
           

modify the !/usr/bin/python3 to !/usr/bin/python3.5. It will ok.

if this solution can’t solve the issue, try to add "LC_ALL=“en_US.UTF-8” to the /etc/default/locale file end. Then it gone.