This should not actually be a minority article
Ubuntu is the most popular among Linux desktop distributions. Although the Linux and Windows families are not on the same scale, the community is still quite active.
There are also many people using Ubuntu desktop systems in China. Of course, most of them are used as virtual machines. Mine is Ubuntu installed on a physical machine. I want to create an all-round programming environment. In fact, I found a problem when developing the backup scanning script before. The pip3 installation library file of Python3 is not directly installed into python3.6.3. This must be very daunting. You can understand it after reading the following introduction!
Ubuntu 16.04 LTS
The long-term support version is chosen for stability. I will definitely reinstall the system when the long-term support version comes out on April 18.
16.04 The Python environment that comes with the version of Ubuntu is Python2.7+ Python 3.5.2
Many core functions in the Ubuntu system use Python a lot, so when programming, I don’t want to add various libraries to the built-in Python and use it for parsing. After all, once it crashes, the system may hang. Moreover, Python 3 is updated very quickly, and it has been released to Python 3.6.4 version. I don't want to use the old version anymore. The above thoughts made me plan to install Python 3.6.4 on the original basis.
Clarify the problem
Ideal state:
Python 2.7 + Python 3.5.2 + Python 3.6.4
python -----> Python 2.7
python2 ----> Python2.7
python3 ----> Python 3.6.3
In fact, the above is all very easy to solve, the key is pip
pip ------> python 2.7
pip3 ----> python3.6.4
python -m pip install package_name ----> python 2.7
python3 -m pip install package_name ----> python 3.6.4
My question before is that python3 corresponds to python3.6.4
But pip3 corresponds to pyhton3.5.2, which leads to a problem. There is no way to add libraries to Python3.6.4. Pyhton does not have a powerful library, and there may be nothing in itself. For example, my previous backup scanning tool called request The library, after that, it was very simple to issue the package. This problem has troubled me for more than a day, and it crashed my system yesterday.
In fact, there are a lot of this problem on the Internet. The key problem is that most of them just did the previous step, which is to install Python 3.6.x, which did not solve the pip3 problem, and then there is no more. What's more, the wrong method is still written there tirelessly. In the end, it succeeded. In the end, even I began to think whether our system was different (in fact, it may be caused by some dependency updates)
Now I will talk about how to do it. Before doing it, consider whether you really have this need.
installation steps
Update and upgrade
sudo apt-get update
sudo apt-get upgrade
Download the source package from the official website
https://www.python.org/downloads/release/python-364/
Unzip the compressed package
tar -xfz Python-3.6.4.tgz
Install dependencies
sudo apt-get install libssl-dev
sudo apt-get install zlib1g-dev
Configure source package
. /configure --with-ssl
The latter parameters are very important
Compile
make
installation
sudo -H make install
This is installed
Verification is successful
python3 -V
The above display shows that the installation is successful
pip3 -V
You can see that pip3 has successfully pointed to python3.6
PS: Explain the place marked in orange just now
If you don't use --with-ssl, everything can be installed successfully after the installation is complete, but when pip3 installs the library files, it will report an error that TLS/SSL cannot be found
Recommended Posts