Install the virtual environment when the problem encountered, the process is very disturbing, here simple and direct sharing, is to solve the problem.
Install the virtual environment (must be in the networked state)
$ sudo pip install virtualenv$ sudo pip install virtualenvwrapper
After installing the virtual environment, if you are prompted to not find the mkvirtualenv command, you must configure the environment variable:
# 1、创建目录用来存放虚拟环境mkdir $HOME/.virtualenvs# 2、打开~/.bashrc文件,并添加如下:export WORKON_HOME=$HOME/.virtualenvssource /usr/local/bin/virtualenvwrapper.sh# 3、运行source ~/.bashrc
Create a virtual environment (Ubuntu must define its own environment name in the networked state)
$ mkvirtualenv scrapy -p python3 # python3虚拟环境
Flask # python2虚拟环境
Enter the appropriate virtual environment and use PIP to install the Python module
$ workon Flask
Exiting a virtual environment
If your environment is a real environment, you will be prompted deactivate: command not found
$ deactivate Flask
Deleting a virtual environment
If your environment is a real environment, you will be prompted deactivate: command not found
$ rmvirtualenv Flask
总结:以上是简单的安装python3和python2的虚拟环境,命令可以直接用,按自己的需要修改虚拟环境名字即可
Python installs virtual environments in Linux, differentiating between Python2 and Python3, installing modules separately