Python Virtualenv - No module named virtualenvwrapper.hook_loader

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

    There are a number of things that can cause this error. If your environment is

    • CentOS 7, with python3 installed from epel-release
    • pip3 installed with python3.4 get-pip.py
    • virtualenvwrapper installed with pip3
    • A python virtual environment made with mkvirtualenv -p /usr/bin/python3.4

    Then, for whatever reason, the virtual environment is created without the virtualenvwrapper library. You can solve it by simply installing it again, but this time from within the virtlualenv

    [user@localhost ~] $ mkvirtualenv -p /usr/bin/python3.4 venv
    Using base prefix '/usr'
    New python executable in /home/user/.virtualenvs/venv/bin/python3.4
    Also creating executable in /home/user/.virtualenvs/venv/bin/python
    Installing setuptools, pip, wheel...done.
    virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/predeactivate
    virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/postdeactivate
    virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/preactivate
    virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/postactivate
    virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/get_env_details
    /home/user/.virtualenvs/venv/bin/python3.4: Error while finding spec for 'virtualenvwrapper.hook_loader' (: No module named 'virtualenvwrapper')
    /home/user/.virtualenvs/venv/bin/python3.4: Error while finding spec for 'virtualenvwrapper.hook_loader' (: No module named 'virtualenvwrapper')
    
    # the virtualenv should now activated
    (venv)[user@localhost ~] $ pip install virtualenvwrapper
    

提交回复
热议问题