Ubantu 安装python
Python installation:
Step 1 – Prerequsities
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Step 2 – Download Python 3.6
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
sudo tar xzf Python-3.6.8.tgz
Step 3 – Compile Python Source
Now use below set of commands to compile Python source code on your system. We use --enable-optimizations option with configure command to enable additional supports like SSL, bz2 support. With make command altinstall, to install it as separate Python, This will not overwrite existing installation.
cd Python-3.6.8
sudo ./configure --enable-optimizations
sudo make altinstall
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
Fix zipimport.ZipImportError: can’t decompress data Error
Sudo apt-get install  zlib*
sudo make altinstall
Step 4 – Check the Python Version
Cd  /usr/local/bin
Run python
调整Python3的优先级,使得3.6优先级较高
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
更改默认值,python默认为Python2,现在修改为Python3
#sudo update-alternatives --install /usr/bin/python  python  /usr/bin/python2.7 100
#sudo update-alternatives --install  /usr/bin/python3  python3  /usr/local/bin/python3.6 150
sudo ln -s /usr/local/bin/python3  /usr/bin/python3
重新建立链接
sudo ln -s /usr/local/bin/python3.6   /usr/bin/python3

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号