由于您拥有自己的python版本,您是否尝试覆盖VIRTUALENVWRAPPER_PYTHON? (似乎您想要export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
)The virtualenvwrapper docs建议在采购virtualenvwrapper.sh之前将envvar设置为所需的python。他们的例子有:
我已经使用自制软件在新的Mac Lion安装上安装了python,并且一直试图通过pip安装virtualenv和virtualenvwrapper,但是当我开始一个新的终端会话时,我得到了这个追溯:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
所使用的python和pip均来自自制软件,但似乎要我使用Apple的默认python。我得到以下]
在我的bashrc中-~$ which python | xargs ls -l lrwxr-xr-x 1 beard admin 33 Jun 24 16:11 /usr/local/bin/python -> ../Cellar/python/2.7.3/bin/python ~$ echo $VIRTUALENVWRAPPER_PYTHON /usr/local/bin/python ~$ which pip | xargs ls -l -rwxr-xr-x 1 beard admin 301 Jun 24 16:18 /usr/local/share/python/pip ~$ which virtualenvwrapper.sh | xargs ls -l -rwxr-xr-x 1 beard admin 32227 Jun 24 16:19 /usr/local/share/python/virtualenvwrapper.sh
但是,似乎认为我已经在
/usr/bin/python
中的系统python中安装了pip(和virtualenv)>编辑:
export WORKON_HOME="$HOME/py-env" export VIRTUALENVWRAPPER_LOG_DIR="$HOME/py-env" export VIRTUALENVWRAPPER_HOOK_DIR="$HOME/py-env" source /usr/local/share/python/virtualenvwrapper.sh export VIRTUALENVWRAPPER_PYTHON="/usr/local/bin/python"
我已经使用自制软件在新的Mac Lion安装上安装了python,并一直尝试通过pip安装virtualenv和virtualenvwrapper,但是当我开始一个新的终端会话时,我得到了这个...]]
由于您拥有自己的python版本,您是否尝试覆盖VIRTUALENVWRAPPER_PYTHON? (似乎您想要export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
)The virtualenvwrapper docs建议在采购virtualenvwrapper.sh之前将envvar设置为所需的python。他们的例子有:
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
为virtualenvwrapper.sh添加或更改〜/ .bash_profile的路径到/usr/local/share/python/virtualenvwrapper.sh
应该看起来像
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python/virtualenvwrapper.sh
我遇到了类似的问题,Hombrew安装的Python与OS X Lion下的系统安装的Python冲突。我以前无法使用Homebrew来解决问题。但是,当我切换到使用pythonbrew(https://github.com/utahta/pythonbrew)管理已安装的Python(而不是Homebrew)时,我能够成功运行virtualenvwrapper。
如果您在ZSH shell中使用PythonBrew和VirtualEnvBurrito,请确保签出.zprofile-其中包含一些命令来执行VirtualEnvBurrito启动脚本。由于.zshrc之前已加载.zprofile,因此Python版本是系统版本。这也会引发此错误。
我在macOS Catalina上面临类似的问题。它随zsh和python 2.7一起提供
通过以下步骤,我安装了python3和虚拟环境,
安装自制软件
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
安装python
brew install python
检查python的安装位置
brew show python
压缩的输出,
==> Caveats Python has been installed as /usr/local/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /usr/local/opt/python/libexec/bin You can install Python packages with pip3 install <package> They will install into the site-package directory /usr/local/lib/python3.7/site-packages See: https://docs.brew.sh/Homebrew-and-Python
macOS上的默认python路径为
/usr/bin/python
,它指向Python 2.7。因此,我们需要创建一个从python到python3的别名alias python=/usr/local/bin/python3
然后按照上述@munchybunch所述的步骤进行,
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh
按照上述步骤,我能够创建一个虚拟环境,
mkvirtualenv dev
由于您拥有自己的python版本,您是否尝试覆盖VIRTUALENVWRAPPER_PYTHON? (似乎您想要export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
)The virtualenvwrapper docs建议在采购virtualenvwrapper.sh之前将envvar设置为所需的python。他们的例子有:
为virtualenvwrapper.sh添加或更改〜/ .bash_profile的路径到/usr/local/share/python/virtualenvwrapper.sh
应该看起来像
我遇到了类似的问题,Hombrew安装的Python与OS X Lion下的系统安装的Python冲突。我以前无法使用Homebrew来解决问题。但是,当我切换到使用pythonbrew(https://github.com/utahta/pythonbrew)管理已安装的Python(而不是Homebrew)时,我能够成功运行virtualenvwrapper。
如果您在ZSH shell中使用PythonBrew和VirtualEnvBurrito,请确保签出.zprofile-其中包含一些命令来执行VirtualEnvBurrito启动脚本。由于.zshrc之前已加载.zprofile,因此Python版本是系统版本。这也会引发此错误。
我在macOS Catalina上面临类似的问题。它随zsh和python 2.7一起提供
通过以下步骤,我安装了python3和虚拟环境,