Python3.5升级3.7

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.

你可能感兴趣的:(Ubuntu16,Python)