Installed virtualenv and virtualenvwrapper: Python says no module named virtualenvwrapper

前端 未结 10 2094
挽巷
挽巷 2021-01-30 01:49

Lots of other threads about similar issues, but none that I could find where quite the same case as mine. So, here goes:

Things I did:

  • Ran
10条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 02:04

    I had the same problem setting up virtualenvwrapper on ubuntu.

    I had installed virtualenv, virtualenvwrapper using pip which installed these modules in the site package of python3.5. How did I find that out?

    Open your terminal and type

    $ pip --version
    

    pip 9.0.1 from /home/clyton/.virtualenvs/test1/lib/python3.5/site-packages (python 3.5)

    Then I checked the variable VIRTUALENVWRAPPER_PYTHON whose value was /usr/bin/python. On your terminal and type

    $ ls -l $VIRTUALENVWRAPPER_PYTHON
    
    lrwxrwxrwx 1 root root 9 Dec 10  2015 **/usr/bin/python -> python2.7**
    

    As you can see this variable is pointing to python2.7 and you may have installed virtualenv in a different python site package.

    So to fix this problem, just add the below line in your bashrc

    VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5
    

    NOTE: Set the above value to the python version with which virtualenv was installed. In my case it was python3.5 so I have set that value. How to find out the python version used to install virtualenv? Again type pip --version in the terminal.

    Then open a new shell session and try mkvirtualenv again. This time it should work.

提交回复
热议问题