When using Python, sometimes they want to install its dependencies does not affect the original system configuration. This time we need to use venv (Virtualenv) to create a virtual Python environment for use. (Like me because there is no permission on the server, there is no way directly through the pip install, but to use such a roundabout way.)
Originally, I already know there are Virtualenv this kind of thing. But this thing needs to be installed, but I do not have permission to install. This is an infinite loop. Later, at the time of check data, accidentally discovered Python3 comes venv, and can directly replace Virtualenv.
It should be noted that, created using "venv" command in Python3.3 the environment does not contain a "pip", you must install it manually. But only on version 3.3 no problem friends.
First, let in a directory (the last is the root directory or the desktop, the key is to be able to find the next use), enter:
$ python -m venv XXX
XXX refers to the name of the file you want to create. Because after executing this command, the will and the Python virtual environment-related files into XXX inside.
After only need to run this inside activate the file on the line. Command under Linux as follows:
$ source <XXX>/bin/activate
Under Windows cmd are:
C:> <XXX>/Scripts/activate.bat
In PowerShell is:
PS C:> <venv>/Scripts/Activate.ps1
However, in order to avoid running untrusted script, the PowerShell script may be prohibited. Now enter the command:
set-executionpolicy remotesigned
Then change the execution policy on it.
Input before exiting environment:
$ deactivate
参考链接:https://www.jianshu.com/p/c5f973fd34d4