-
pip3 install virtualenv virtualenvwrapper
注:自己安装了Python3.6,位置:/usr/local/python3/bin/python3 - 获取virtualenv 与 virtualenvwrapper.sh的位置
-
virtualenv
:/usr/local/python3/bin/virtualenv -
virtualenvwrapper.sh
:/usr/local/python3/bin/virtualenvwrapper.sh
注:使用pip安装 位置与对应Python版本的位置一致
- 创建虚拟环境存放路径
mkdir /home/python_env/.virtualenv
- 设置环境变量,把下面四行添加到~/.bash_profile里
export WORKON_HOME=/home/python_env/.virtualenv
export VIRTUALENVWRAPPER_PYTHON=/usr/local/python3/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/python3/bin/virtualenv
source /usr/local/python3/bin/virtualenvwrapper.sh
- 执行命令
source ~/.bash_profile
上面完美解决:/usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh ......问题