无法导入模块virtualenvwrapper.hook_loader

时间:2018-01-14 19:34:20

标签: python macos virtualenvwrapper

根据几个有用的相关问题的建议和指导,我已经打了几个星期这个问题,但仍然无法解决。我试图解决这个问题,不止一次卸载并重新安装了easy_install,pip,virtualenv和virtualenvwrapper。当我发送.bashrc时,我收到以下错误:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals
  File "/usr/local/lib/python2.7/site-packages/virtualenvwrapper/hook_loader.py", line 16, in <module> from stevedore import ExtensionManager
ImportError: No module named stevedore
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7 and that PATH is
set properly.

这是我的.bashrc文件:

#set -x
if [ -f /usr/local/bin/virtualenvwrapper.sh ] ; then
  source /usr/local/bin/virtualenvwrapper.sh
fi
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
export PATH=/usr/local/sbin:$PATH
export PATH=/usr/local/bin:$PATH
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
export PROJECT_HOME=$HOME/dev

我尝试将VIRTUALENVWRAPPER_PYTHON更改为/ usr / local / bin / python - 这给了我同样的错误,而不是2.7。我也试着注释掉指向2.7二进制文件的导出PATH行。这也没有用。我认为我尝试了很多事情,我可能会遇到严重破坏的事情。如果它有帮助,我使用Homebrew安装了Python,我安装了2.7.13和3.6.3。在我的/ usr / local / bin目录中,我的Python符号链接如下:

lrwxr-xr-x  1 Scott  admin  34 Apr 11  2017 python -> ../Cellar/python/2.7.13/bin/python
lrwxr-xr-x  1 Scott  admin  41 Apr 11  2017 python-config -> ../Cellar/python/2.7.13/bin/python-config
lrwxr-xr-x  1 Scott  admin  35 Apr 11  2017 python2 -> ../Cellar/python/2.7.13/bin/python2
lrwxr-xr-x  1 Scott  admin  42 Apr 11  2017 python2-config -> ../Cellar/python/2.7.13/bin/python2-config
lrwxr-xr-x  1 Scott  admin  37 Apr 11  2017 python2.7 -> ../Cellar/python/2.7.13/bin/python2.7
lrwxr-xr-x  1 Scott  admin  44 Apr 11  2017 python2.7-config -> ../Cellar/python/2.7.13/bin/python2.7-config
lrwxr-xr-x  1 Scott  admin  35 Nov  2 23:06 python3 -> ../Cellar/python3/3.6.3/bin/python3
lrwxr-xr-x  1 Scott  admin  42 Nov  2 23:06 python3-config -> ../Cellar/python3/3.6.3/bin/python3-config
lrwxr-xr-x  1 Scott  admin  37 Nov  2 23:06 python3.6 -> ../Cellar/python3/3.6.3/bin/python3.6
lrwxr-xr-x  1 Scott  admin  44 Nov  2 23:06 python3.6-config -> ../Cellar/python3/3.6.3/bin/python3.6-config
lrwxr-xr-x  1 Scott  admin  38 Nov  2 23:06 python3.6m -> ../Cellar/python3/3.6.3/bin/python3.6m
lrwxr-xr-x  1 Scott  admin  45 Nov  2 23:06 python3.6m-config -> ../Cellar/python3/3.6.3/bin/python3.6m-config
lrwxr-xr-x  1 Scott  admin  35 Apr 11  2017 pythonw -> ../Cellar/python/2.7.13/bin/pythonw
lrwxr-xr-x  1 Scott  admin  36 Apr 11  2017 pythonw2 -> ../Cellar/python/2.7.13/bin/pythonw2
lrwxr-xr-x  1 Scott  admin  38 Apr 11  2017 pythonw2.7 -> ../Cellar/python/2.7.13/bin/pythonw2.7

...我的$ PATH是:

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin

1 个答案:

答案 0 :(得分:0)

如果您使用的是Python2,则可能是从另一个Python版本安装了一个pakage。试试这个:

$ sudo pip3 install virtualenvwrapper