Python Virtualenv - No module named virtualenvwrapper.hook_loader

前端 未结 16 1423
野趣味
野趣味 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:13

    Just bumped into this issue on a Centos 7.4.

    None of the above answers suited my case. After quite a bit of digging around I pinpointed this to too-strict file permissions in python libs (I guess python installation on Centos differs a bit from other POSIX systems).

    So, if everything else fails you might want to check that your python libs are readable by the user you're trying to run virtualenvwrapper with.

    In particular check: /usr/lib/python3.6 /usr/lib64/python3.6 (amend the paths for different python versions).

    If you see that group and others lack read and execute permissions in there then add them: sudo chmod og+rx -R /usr/lib/python3.6 sudo chmod og+rx -R /usr/lib64/python3.6

    Note: I'm not sure whether this works against a Centos security policy but it's probably safe as long as you don't give write persmisions.

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

    In my situation (OS X 10.13.6), this did it

    brew install python2 --upgrade
    
    0 讨论(0)
  • 2020-12-02 06:18

    The issue was solved following the steps below:

    #switch the /usr/bin/python link to point to current python link
    cd /usr/bin
    sudo mv python python.bak
    sudo ln -s /Library/Frameworks/Python.framework/Versions/Current/bin/python python
    

    Re-arrange the export command in order that it is placed before the virtualenv commands in my .bash_profile file:

    PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
    export PATH
    
    # needed for virtualenvwrapper
    export WORKON_HOME=$HOME/.virtualenvs
    source /usr/local/bin/virtualenvwrapper.sh
    

    Re-Install setuptools, easy install and PIP. This is obviously needed in order that they work properly with the new python version:

    sudo sh setuptools-0.6c11-py2.7.egg
    
    sudo easy_install-2.7 pip
    
    pip install virtualenv
    
    0 讨论(0)
  • 2020-12-02 06:19

    Also, if you have macports, make sure /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin is listed before /Library/Frameworks/Python.framework/Versions/2.7/bin and /usr/local/bin in PATH. Then set the following in you .profile:

    export VIRTUALENVWRAPPER_PYTHON=`which python`
    export VIRTUALENVWRAPPER_VIRTUALENV=`which virtualenv`
    source `which virtualenvwrapper.sh`
    
    0 讨论(0)
  • 2020-12-02 06:27

    This happened to me and I solved it by re-installing pip. What had happend was that which pip gave /usr/bin/pip as a result, while which python gave /usr/local/bin/python. The path for pip should be /usr/local/bin/pip. This probably broke when I updated my Python installation.

    If you follow the pip documentation you can easily reinstall pip for your current working Python setup. You need to:

    1. Download the get-pip.py script (directly linked from pip's documentation).
    2. Run python get-pip.py.

    This solved the problem for me.

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

    Try to uninstall your virtualenv and virtualenvwrapper and install it again using pip in version 2.7 (I think).

    I encountered the same error and I just did this and solved my problem.

    I using U

    0 讨论(0)
提交回复
热议问题