1. 程式人生 > 其它 >Ubuntu環境下的python 版本升級

Ubuntu環境下的python 版本升級

技術標籤:devopspythonlinuxubuntu

一、make install (失敗的)

1、wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
2、tar -xzvf Python-3.7.0.tgz
3、cd ./Python-3.7.0
4、./configure
    果然報錯:make: *** No targets specified and no makefile found. Stop.
    我也曾嘗試解決這個問題,但是在公司時間也有限,就只能尋求他法了
5、make
6、make install
7、make clean
8、make distclean
9、mv /usr/bin/python /usr/bin/python3.7.0
10、ln -s /usr/local/bin/python3.7 /usr/bin/python
11、vi /usr/bin/yum
    找到第一行#!/usr/bin/python 改為 #!/usr/bin/python3.7.0

二、PPA (成功的)

新增PPA
    sudo add-apt-repository ppa:jonathonf/python-3.6
更新
    sudo apt-get update 
    sudo apt-get install python3.6
        可能會報錯,按照提示解決就好
             sudo dpkg --configure -a 
更換python的預設版本
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
python -V