Virtualenv is a common virtual environment in Python. virtual machines that can be understood as belonging to Python.
On Linux and Mac systems, the VIRTUALENV environment is very convenient to configure, but on the Windows platform is more trouble, recorded and shared with you.
Install Python
Note: This configuration of the Python version is 2.7.X, that is, the old version, the new version of Python 3.X Some libraries are not supported, so it is not used.
The configuration of the Python 2.7.x under window does not say much, there is a lot of information on the Web, you can see here. Just download the 2.7.X version when downloading. Also, remember to add the Python directory to the system directory under Path .
Install PIP
What is PIP? The official online answer is:A Tool for installing and managing Python packages.
Intuitively speaking, the installation of Pip, joined the path system directory, command Line (CMD) under a more command, called PIP. Use this command to automatically download various third-party libraries that install Python.
The process of installing PIP is shown here.
To put it bluntly, the command line uses Python to execute two. py files: ez_setup.py and get-pip.py. Also, remember to add the Scripts folder under the Python directory to the system directory path .
Installing Virtualenv
After installing PIP, it is easy to install virtualenv and enter it directly under the cmd command line:
>pip Install Virtualenv
Wait for the download to download automatically and install it well. Then enter a command under the folder where you want to create the virtual Python environment:
>virtualenv venv
Look again, is not the current directory of CMD is more than a venv folder? This folder is where you save the Python virtual environment.
Turn virtualenv on and off
In the Windows environment, enter the VENV (which is the Virtual Environment folder you created yourself) folder and type the command:
>scripts\activate
Always CD find inside the Scripts file, execute the file activate directly under the command line (like the. exe file, enter the name directly on the command line)
At this point you will find that the command line has become:
More than one (venv) of the previous representative entered the virtual environment. In this area, you can use PYTHON,PIP and other commands, all virtualenv help you configure. You can download other libraries yourself.
If you need to close this virtual environment, enter deactivate, the return is good.
Attention:
The virtual environment created by Virtualenv is completely unrelated to the host's Python environment, and your host-configured libraries cannot be used directly in virtualenv. You need to install the configuration again using Pip install in a virtual environment before you can use it.
WINDOWS+PYTHON+VIRTUALENV Environment Configuration