summarize
Because Python 3 has had several jumps in updates, a large number of software programs that use Python 3 as a development tool are strictly limited to Python 3 versions, such as Python 3.8 - Python 3.9. This requires developers to have multiple versions of python in their development environment. In the case of Ubuntu and otherLinux This article will give you a simpler way to install multiple versions of Python, since Python is installed using the source code compilation method, which is not friendly to some Python developers.
mounting
The Ubuntu 22.04 I am using comes with Python 3.10 version of Python, you can use the following command to check the version of Python that comes with the system.
python3 --version
- 1
The author wishes to install Python 3.9 and create the relevantvirtualized environment。
First, we need to introduce a new apt source as follows.
add-apt-repository ppa:deadsnakes/ppa
- 1
deadsnakes gives a large number of installers for Python versions in its repositories, all of which arepre-compileOkay, we don't need to do any further compilation.
To install Python 3.9, for example, the command would be.
apt install python3.9
- 1
Once the installation is complete, we can use the following command to view thePython3.9 Was the installation successful.
python3.9 --version
- 1
Next, with multiple versions of Python, setting up a virtual environment is a must, using the following command to install the virtual environment suite.
apt install python3.9-venv
- 1
Use the following commandCreating a Virtual Environment:
python3.9 -m venv test
cd test
- 1
- 2
usingsource bin/activate
command to activate the virtual environment, readers can use thepip
command to install the relevantpip
package. After the virtual environment is activated, thepython3 --version
The output has also changed, indicating that Python 3.9 in the virtual environment masks the external Python version, which is useful for multi-version management. Finally, the reader can use thedeactivate
Exit the virtual environment.
Space limitations prevent us from presenting information onvenv
The reader is invited to refer to the full extent of the(computer) file。
Finally, some readers may install some specialpip
packages, such asfastecdsa
etc. These packages are written in C and need to be compiled during installation. To solve the problem with these packages, I recommend that the reader install the following libraries.
apt install python3.9-dev
- 1
This library installs the Python 3.9 development tools, and the package is necessary for libraries that need to be compiled and installed.