Python Virtualenv - No module named virtualenvwrapper.hook_loader

前端 未结 16 1483
野趣味
野趣味 2020-12-02 06:01

I\'m running Mac OS 10.6.8. and wanted to install in addition to python 2.6 also python 2.7 and use python 2.7 in a new virtualenv. I executed the following steps:

I

相关标签:
16条回答
  • 2020-12-02 06:36

    I just installed python 3.5,tried the virtualenvwrapper and then had this problem. I came to realize that python3.5 was installed in /usr/local/bin/python3.5 and NOT /usr/bin/python3.5. So, I revised my .bash_profile script to look like the following and everything seems to work now

    # Setting PATH for Python 3.5
    # The orginal version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
    export PATH
    export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
    export WORKON_HOME=$HOME/.virtualenvs
    source /Users/bentaub/.virtualenvs/djangodev/bin/virtualenvwrapper.sh
    

    I'm enough of a novice to not be sure how that 'local' in the path to python3.5 is going to affect me in the long run but, for now, it works.

    0 讨论(0)
  • 2020-12-02 06:36

    Even though there is an accepted answer I thought I would put what fixed it for me.

    Firstly I installed Python and had just upgraded it via Homebrew. I am also using ZSH so if some bits don't quite match your output then that might be why.

    By running brew info python and looking through the output I found the following nice bit of information:

    If you wish to have this formula's python executable in your PATH then add
    the following to ~/.zshrc:
        export PATH="/usr/local/opt/python/libexec/bin:$PATH"
    

    So I added this to my terminal startup script as shown and the error n longer displays.

    Note: I inserted this into another part of my PATH and the error persisted on start up.

    0 讨论(0)
  • 2020-12-02 06:37

    I get the same error . Found out I had old version of pip . I fixed the error by simply upgrading the pip .

    0 讨论(0)
  • 2020-12-02 06:37

    I had this problem after uninstalling the virtualenvwrapper package. When I logged in to any user (or su to a different one), I would get:

    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.
    

    The solution was to delete the /etc/bash_completion.d/virtualenvwrapper file.

    Edit:

    Do not delete the above file or it won't be recreated if you reinstall virtualenvwrapper. Instead what you need to do is purge the virtualenvwrapper package when you uninstall it. Like this on Debian:

    apt-get remove --purge virtualenvwrapper
    
    0 讨论(0)
提交回复
热议问题