我最近通过brew(也是python2 via brew)安装了python3,并且没有触及系统python(新的笔记本电脑macOS)。
然后我用pip3 install virtualenvwrapper
然后在我的shell(zsh)中我添加了
#set python3 as the default for new virtualenvs
$ export VIRTUALENV_PYTHON=python3
# set where virtual environments will live
export WORKON_HOME=$HOME/.virtualenvs
# set the folder for projects
export PROJECT_HOME=$HOME/PycharmProjects
# ensure all new environments are isolated from the site-packages
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
# use the same directory for virtualenvs as virtualenvwrapper
export PIP_VIRTUALENV_BASE=$WORKON_HOME
# makes pip detect an active virtualenv and install to it
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
source /usr/local/bin/virtualenvwrapper.sh
else
echo "WARNING: Can't find virtualenvwrapper.sh"
fi
然而,无论何时我运行mkvirtualenv
或我收到错误:
...
Installing setuptools, pip, wheel...done.
/usr/bin/python: No module named virtualenvwrapper
即使mkvirtualenv
命令似乎按预期工作。但是,mkproject
并不执行workon
命令。
答案 0 :(得分:1)
您使用pip3在python3中安装了virtualenvwrapper,但在运行mkvirtualenv时访问了python2
使用别名技术将python3设置为默认值。您可以通过https://stackoverflow.com/a/18425592/5334188
完成此操作还要检查virtualenvwrapper.sh路径,使用哪个