# If you have installed python3.6, delete
$ apt-get remove --purge python3.6
Then download the source code from the source code and build and prepare the build system:
wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
Build a python environment, installation package required:
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
Now configuration, production, production altinstall (important)
$ tar xvf Python-3.6.7.tgz $ cd Python-3.6.7/ $ ./configure --enable-optimizations --with-ensurepip=install $ make altinstall
# Now verify the installation by runnning
$ python3.6 -V which python3.6
Copy python3.6 path, it should be /usr/bin/python3.6 or /usr/local/bin/python3.6
You can now use the update-alternatives to manage all versions of python on your computer
$ ls /usr/bin/python* # e.g. /usr/bin/python2.7 /usr/bin/python3.4 $ /usr/bin/python3.6 $ update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 $ update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1 $ update-alternatives --install /usr/bin/python python /usr/local/bin/python3.6 2
- The number 2 indicates the priority python running on your computer. In this case, 2> 1, so you prefer python3.6. If you want to change to version 3.4, you can run update-alternatives -config python, which is an interactive configuration program.
- Now you can use python -m pip -V to verify pip is working properly. You can also use pip3.6 to install the package.
Have any questions, suggestions, comments, or add QQ group: 780 450 250