2

I'm working through Hitchhiker's Guide to Python's section on virtualenvwrapper, but am having difficulty creating a virtualenv. I don't receive any error when I try to create a virtualenv, but when I try to workon it, an error is thrown saying the env doesn't exist. My WORKON_HOME is empty. What might be the matter?

$ mkvirtualenv test
# NOTHING PRINTS HERE
$ workon test
ERROR: Environment 'test' does not exist. Create it with 'mkvirtualenv test'.
$ workon
# NOTHING PRINTS HERE

Relevant lines from my .bashrc, drawing on this question and the official installation guide:

export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Documents/Coding
source /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh
mrwnt10
  • 1,234
  • 1
  • 17
  • 28
  • Looks like on the docs(https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html) the order of commands is different that yours. workon then mkvirtualenv test. – griffin_cosgrove Jul 29 '19 at 02:11
  • 1
    @griffin_cosgrove I believe they just run `workon` first to show that there are no virtual environments existing at that time, but then after creating a virtual environment with `mkvirtualenv`, `workon` will now show the new environment. I tried doing it in this order and it didn't change anything. – mrwnt10 Jul 29 '19 at 02:36
  • I am not familiar with this library but there are other ways to make virtual environments. – griffin_cosgrove Jul 29 '19 at 02:41
  • 1
    Is `virtualenvwrapper.sh` sourced? `type -a mkvirtualenv`? Run `exec bash -x` and then `mkvirtualenv test` to see where it stops. – phd Jul 29 '19 at 09:45
  • @phd My `bash_profile` includes these lines ```export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 export VIRTUALENVWRAPPER_VIRTUALENV=/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/Documents/Coding source /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh``` – mrwnt10 Jul 30 '19 at 02:27
  • @phd When following your commands, it stops with these lines: ```+ '[' -n '' ']' + virtualenvwrapper_cd /Users/ME/.virtualenvs + '[' -n /bin/bash ']' + builtin cd /Users/ME/.virtualenvs + /Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh test + '[' -d /Users/ME/.virtualenvs/test ']' + typeset RC=1 + '[' 1 -ne 0 ']' + return 1``` – mrwnt10 Jul 30 '19 at 02:29
  • 1
    I suspect the problem in this command: `/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh test`. It must be `virtualenv`, not `/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh`. You don't set `VIRTUALENVWRAPPER_VIRTUALENV` env var? – phd Jul 30 '19 at 09:03

1 Answers1

0

Deleting the line

export VIRTUALENVWRAPPER_VIRTUALENV=/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh

from my .bashrc and re-sourcing the terminal solved the problem. I had mistakenly provided the path to virtualenvwrapper instead of virtualenv like the .bashrc did in the question I drew from.

mrwnt10
  • 1,234
  • 1
  • 17
  • 28