Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtualenv - workon command not found

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

like image 400
Renzo Rodrigues Avatar asked Jan 05 '16 12:01

Renzo Rodrigues


People also ask

What is Workon command?

Use the workon createdenv command to subsequently activate a virtual environment or just run workon to list all available virtual environments created. You can navigate to other created virtual environments while on a given environment without necessarily deactivating it first. workon createdenv.

What is Workon Virtualenv?

virtualenv. A Virtual Environment enables us to keep the dependencies required by different projects in separate places, by creating virtual Python environments. In other words, virtualenv is a tool to create isolated Python environments.

Where is Virtualenvwrapper installed?

Now you want to create a virtual environment for the project that you want to work on. To create our virtual environment we will be using virtualenvwrapper. That installation installs virtualenvwrapper in the /usr/local/bin directory.


2 Answers

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.

like image 113
erip Avatar answered Oct 08 '22 05:10

erip


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.

like image 32
Muhammad Tahir Avatar answered Oct 08 '22 06:10

Muhammad Tahir