PythonWeb framework Django: virtual environment installation (virtualenv)

Usefulness of the virtual environment:

When we have multiple projects to use different third-party libraries, a conflict occurs, because only allows one version of the third-party libraries within Python environment.

For example, there are A, B two Web projects, but Django environment A project is 2.0.6, but Django project's environmental B 2.2.6 this time if Django environment on our computer, then to 2.0.6 a project can only run up,

The B version of the project environment that Django does not fit, we can only uninstall the original 2.0.6 2.2.6 reinstall one of Django

Of course, if this is only a third-party libraries, better said, but if there are dozens of third-party libraries, it would be a disaster.

So this time we need to build Python virtual environment!

First we need to install third-party libraries virtualenv to create our virtual environment, you can use pip install image (the blog before I speak there)

After we have to enter we want to enter cmd command prompt, enter the environment we want to create a virtual directory

Here I default for the C drive directory

 

 

Then we use the command name virtualenv virtual environment to create a virtual environment where my name is TestDemo 

 

Then we can go to the File Explorer to view the inside of the virtual environment

 

 

 And we will TestDemo open configuration can be found in the virtual environment and the python default configuration is the same environment

At this point we open the Lib directory can be found inside the library are all built-in library python, not a third-party libraries.

This time, when we created the project can be directly used as the python virtual environment of our operating environment

Activating virtual environment

Open cmd
Use cmd into the Scripts directory under the virtual environment directory
execute commands activate in Scripts directory

 

 

Run the installation of third-party libraries such as: pip install ~

 

 

 

 Here we build a python virtual environment will be finished!

 

Guess you like

Origin www.cnblogs.com/gongdada/p/11444338.html