Ubuntu16.04系统自带两个python版本,一个是python2.7,很快就不会维护了,另一个是python3.5,但是目前很多最新库,尤其是深度学习相关的库要求python3.6以上,所以要升级。
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
other versions:https://www.python.org/downloads/source/
Enter the download directory
tar zxvf Python-3.7.3.tgz
cd Python-3.7.3
./configure --with-ssl
make
sudo make install
attention: the option --with-ssl in order to avoid install error when using pip install
sudo rm -rf /usr/bin/python3
sudo rm -fr /usr/bin/pip3
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
python3 -V
pip3 -V
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.