我是Python虚拟环境的新手,所以在阅读this tutorial之后,我尝试使用virtualenvwrapper创建我的第一个环境.我的python3安装现在是裸机:
$pip3 list
argparse (1.2.1)
pip (1.5.6)
setuptools (2.1)
stevedore (0.15)
virtualenv (1.11.6)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.3.1)
根据教程的建议,我在.bashrc文件中添加了以下行:
export WORKON_HOME=$HOME/.virtualenvs
source /Library/Frameworks/Python.framework/Versions/3.4/bin/virtualenvwrapper_lazy.sh
当我打开一个新终端时会产生以下消息:
Last login: Wed Sep 10 22:33:17 on ttys006
-bash: _VIRTUALENVWRAPPER_API: unbound variable
-bash: VIRTUALENVWRAPPER_SCRIPT: unbound variable
-bash: VIRTUALENVWRAPPER_SCRIPT: unbound variable
-bash: _VIRTUALENVWRAPPER_API: unbound variable
-bash: _VIRTUALENVWRAPPER_API: unbound variable
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
我不明白问题是什么,但很明显源/Library/Frameworks/Python.framework/Versions/3.4/bin/virtualenvwrapper_lazy.sh行失败,因为我甚至找不到mkvirtualenv命令:
$mkvirtualenv test1 -p /usr/bin/python3.3
-bash: mkvirtualenv: command not found
我找到了this post和this one,有类似的问题,但没有一个给我一个解决方案.
解决方法:
我在.bashrc中添加了以下内容,引用了this
export PATH=/usr/local/bin:$PATH
source /usr/local/bin/virtualenvwrapper.sh
现在mkvirtualenv工作 –
pkoli@pkoli-SVE15136CNB:~/Desktop$mkvirtualenv BUGS
Using base prefix '/usr'
New python executable in BUGS/bin/python3
Also creating executable in BUGS/bin/python
Installing setuptools, pip...done.