Ubuntu used to create a virtual environment in venv python3

Did not know Python3 built into venv module, has been using is virtualenv module, venv virtualenv easy to use compared to many, you can replace virtualenv

First, the installation package venv:

$ sudo apt install python3-venv

Second, create a virtual environment

First create a project folder, the virtual environment will be installed in the project folder, I project files folder used here is myproject, enter mypeoject folder, execute the command:

$ python3 -m venv venv

Then the virtual environment has been created, the default setting is Python3

Third, activate the virtual environment

In the project folder, file execution activate activate a virtual environment

source venv/bin/activate

Fourth, create a project

You can see the project folder in addition to the virtual environment file venv, there is no project file, you can use pip tools you need to install any framework, such as flask, django

Fifth, exit the virtual environment

deactivate

 

Guess you like

Origin www.cnblogs.com/Horace-blogs/p/11570624.html