Compile and install from source code to upgrade to python39

Apart from anything else, directly build from source code

compile method

wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz 
xz -d Python-3.9.7.tar.xz
tar -xvf *.tar
sudo apt install libffi-dev  #不然会出现 _ctype 错误
sudo apt install libssl-dev  #pip3 支持ssl
./configure --prefix=/usr/local/python3
make && sudo make install
sudo ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
sudo ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

You can replace Python-3.9.7.tar.xz with the latest python package

think deeply

  • You need to fully enable python3, don't hold on to python2 anymore, no matter in terms of performance or grammatical features, py3 is making progress
  • It is rare to build and install directly now. When I was responsible for the production line before, the 3-piece set of nginx-php-mysql was installed in batches with scripts. I remember that there is a package LNMP , which can be installed in place at one time with scripts.
  • Install the operating system, choose the version above ubuntu20, the default is python3.8

Guess you like

Origin blog.csdn.net/victorc666/article/details/124561227