Installed virtualenv and virtualenvwrapper: Python says no module named virtualenvwrapper

前端 未结 10 2294
挽巷
挽巷 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:05

    I realize this thread is super old but I got stuck on it while trying to find a solution to this problem (using pip3 but you can swap pip as necessary).
    I ended up using a modified version of a solution that I found in another post here.
    Add the following to your .zshrc/.bashrc:
    source /usr/local/bin/virtualenvwrapper.sh
    export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3

    I had to add local in the above but guessing that whether or not you need to do so will depend on your installation. I realized I was referencing the wrong location because I was getting this error: zsh: no such file or directory: /usr/bin/python3 so I just did which python3 to see where it lived.

    Make sure you uninstall any existing versions of virtualenv and virtualenvwrapper as you can not simply install to a new location with an existing version on your machine, you must delete the old version and then install the new version in the new location.

    To install:
    sudo /usr/local/bin/pip3 install virtualenv virtualenvwrapper

    And, as per this post, you should be able to create a virtual environment with your version of python3 using this command: mkvirtualenv --python=which python3 nameOfEnvironment

提交回复
热议问题