When developing Python applications, there is only one version of Python3 installed on the system: 3.4. All third-party packages will be pip
installed into the Python3 site-packages
directory.
If we want to develop multiple applications at the same time, then these applications will share a Python, which is Python 3 installed on the system. What if app A needs jinja 2.7 and app B needs jinja 2.6?
In this case, each application may need to have its own "independent" Python runtime environment. Virtualenv is used to create an "isolated" Python runtime environment for an application.
For the construction of the specific python environment variables, everyone can use baidu. I will not build it here.
pip install virtualenv
If you are a woolen Internet user, the domestic shielding is very powerful, and you can do it through Douban. Reminder that there is a relatively new package Douban source not necessarily available.
pip install -i https://pypi.douban.com/simple/ virtualenv
The default virtual environment directly binds the python path specified by the current python command
If you need to bind a specific python version, you need to execute the command
virtualenv -p D:\Python\Python36\python.exe scripy3
How to uninstall when in a bad mood
pip uninstall virtualenv
-------------------------------------------------- ---------The above is how to install the plugin------------------------------------ --------------------
Create a project project: testproject
virtualenv testproject
Enter the testproject project
CD test project;
cd Scripts;
Enter the virtual project:
activate.bat;
Exit the virtual project:
deactivate.bat
The path to the displayed project is
(testproject) E:\scr\Scripts>python Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
It 's too damn troublesome to record the path every time through virtualenv, foreigners are good at simplification
There is a very useful virtual environment management package under windows
pip install virtualenvwrapper-win
To display the project, it is recommended to configure an environment variable name first: WORKON_HOME=E:\Evns
workon
Create project
mkvirtualenv py3scarpy
Enter the project by default
If you want to enter the specified item:
workon py3scarpy
This is my own project
(py3scarpy) E:\Evns\py2scrapy\Scripts>
You can pip install some plugins at will in this project to make you feel good and happy.
In addition, specify the version of python under the description
mkvirtualenv py33scarpy --python=D:\Python\Python36\python.exe