"virtualenv与此系统或可执行文件不兼容"使用虚拟环境和anaconda

pat*_*kil 6 python virtualenv anaconda

我正在尝试使用virtualenv启动虚拟环境,我收到此错误:

Already using interpreter /Users/pkilcrease/anaconda/bin/python3
Using base prefix '/Users/pkilcrease/anaconda'
New python executable in /Users/pkilcrease/.virtualenvs/bodega/bin/python3
Also creating executable in /Users/pkilcrease/.virtualenvs/bodega/bin/python
ERROR: The executable /Users/pkilcrease/.virtualenvs/bodega/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Users/pkilcrease/.virtualenvs' (should be '/Users/pkilcrease/.virtualenvs/bodega')
ERROR: virtualenv is not compatible with this system or executable
Run Code Online (Sandbox Code Playgroud)

我正在运行的命令是 mkvirtualenv -a . --no-site-packages --python='which python3' -r requirements.txt bodega

我的.bashrc文件目前看起来像这样:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/Users/pkilcrease/anaconda/bin/virtualenvwrapper.sh
source /Users/pkilcrease/anaconda/bin/virtualenvwrapper_lazy.sh
Run Code Online (Sandbox Code Playgroud)

我觉得anaconda和virtualenv存在一些问题,导致这里的问题,但不知道如何解决这个问题,或者它是否只是一个红鲱鱼.

mic*_*ael 1

如果使用 conda python 可执行文件,请使用(注意conda 附带conda create --name {your_venv} python=3 一个实用程序,但仍用于创建新的虚拟环境)。virtualenvconda create...

否则,当使用系统包管理器安装的 python 版本时,请使用virtualenv或最好使用virtualenvwrapper实用程序创建虚拟环境mkvirtualenv。例如,在 Linux 上,“系统 python”是/usr/bin/python3/usr/bin/python/usr/bin/python2等。或者,很明显您在 MacOS 上,这可能是由brew(homebrew) 或port(macports) 在/opt或中安装的 python /usr/local。您可能必须安装virtualenvwrapper才能获取mkvirtualenv(和lsvirtualenv等)。

简而言之,如果您使用 anaconda python,请坚持使用condautils。另外,如果您保持 Python 的自由和开放(正如您的许多公司 IT 数据中心所做的那样),那么可以使用任何各种开放实用程序mkvirtualenv,例如 等。