简体   繁体   中英

Cannot import module virtualenvwrapper.hook_loader

I've been fighting this issue for weeks, following the advice and guidance of several helpful related questions, but still cannot resolve. I uninstalled and reinstalled easy_install, pip, virtualenv, and virtualenvwrapper on more than one occasion trying to resolve this issue. When I source .bashrc I get the following errors:

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.

Here is my .bashrc file:

#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

I tried changing VIRTUALENVWRAPPER_PYTHON to /usr/local/bin/python - that gives me the same error sans the 2.7. I also tried commenting out the export PATH line pointing to the 2.7 binary. That didn't work either. I think that I've tried so many things that I probably have things severely botched up. If it helps, I installed Python using Homebrew and I have 2.7.13 and 3.6.3 installed. In my /usr/local/bin directory my Python symbolic links are as follows:

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

...and my $PATH is:

$ 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

If you are using Python2, you probably installed a pakage from another Python version. Try this:

$ sudo pip3 install virtualenvwrapper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM