Creating a Python virtual run environment with VIRTUALENV
When you write a Python program, you typically use some third-party library files. and different projects usually call different third-party libraries. If all the projects are mixed together, this is obviously not easy to manage. Virtualenv is a virtual environment management tool.
$ sudo pip install virtualenv
$ virtualenv Project1
$ source./project1/bin/activate
(Project1) [Email protected]:~$
Create a Python virtual run environment using VENV
Python version 3.3 and above has a venv module in the standard library, and this module and virtualenv implement similar functions. If your system does not contain a venv module, we can also install it by command.
$ sudo apt-get install python3-venv
$ python3-m venv VENV1
$ source Venv1/bin/activate
(VENV1) [Email protected]:~$
Create a coexistence of different versions using pyenv
The main function in the previous two methods is to implement different Python runtime environments in one operating system, with the same Python version of the software. Pyenv is a good choice if we want to quickly save a different Python version of the operating environment. Pyenv is an open source project whose source code is hosted on GitHub and GitHub's address is https://github.com/pyenv/pyenv.
$ sudo apt-get update
$ sudo apt-get install make build-essential libssl-dev Zliblg-dev
$ sudo apt-get install Libbz2-dev libreadline-dev libsqlite3-dev wget Curl
$ sudo apt-get install LLVM libncurses5-dev Libncursesw5-dev
$ curl-l Https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | Bash
$ pyenv Update
$ pyenv Install-list
$ pyenv Install 3.6.2
It may take some time to install a new version of Python. The new Python version is installed directly from the source code due to different operating system environments. After the installation is complete, we can view the software version on the current system.
$ pyenv Versions
Set the global Python software version
$ pyenv Global 3.6.2
$ pyenv Versions
At this point, when we execute the Python program again, we have already used the 3.6.2 version.
Creating a Python runtime environment using Docker
Links: https://www.oschina.net/translate/using-docker-as-a-python-development-environment
Build Python's Running environment