Virtualenv - workon command not found
Asked Answered
W

2

27

I followed these steps to set up virtualenv + virtualenvwrapper:

$ sudo apt-get install python3-pip

$ sudo pip3 install virtualenv
$ sudo pip3 install virtualenvwrapper

$ mkdir ~/.virtualenvs

$ export WORKON_HOME=~/.virtualenvs

$ VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'

$ source /usr/local/bin/virtualenvwrapper.sh

$ mkvirtualenv venv
$ virtualenv venv

So far it was working fine but I restarted the shell and then I tried workon venv and now it says: command not found

Wei answered 5/1, 2016 at 12:10 Comment(0)
S
67

So far it was working fine but I restarted the shell

The reason is because you restarted the shell.

If you want this to work with each shell, you'll need to add these to your ~/.bashrc file:

export WORKON_HOME=~/.virtualenvs
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper.sh

After adding this, you'll want to source ~/.bashrc so the changes take effect. You'll find that you have access to virtualenvwrapper facilities in each new shell.

Spiffing answered 5/1, 2016 at 12:15 Comment(5)
You may have to add this to .bash_profile instead.Pastorale
It works but I have to do source ~/.bashrc each time I open a new terminal window or labelAndrus
@JesusAlmaral-Hackaprende Did you read the comment right above yours?Spiffing
Yes, what I had to do was instead of using ~/.bashrc I used ~/.zshrc, this is for Mac Big SurAndrus
From many virtualenvwrapper stack overflow Q & A-s this is the correct answer. Tank you.Honaker
B
9

You need to add commands

export WORKON_HOME=~/.virtualenvs
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper.sh

to your ~/.bashrc file. So that whenever you start shell these commands are loaded automatically.

For the reference.

Buckling answered 5/1, 2016 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.