E
E
evve2015-05-05 17:40:06
Django
evve, 2015-05-05 17:40:06

How to properly configure virtualenvwrapper?

Hi all!
I recently decided to try virtualenvwrapper. I found the instruction https://virtualenvwrapper.readthedocs.org/en/lates...
I doubt that I did everything right and ask you to tell me.
So, I put:
sudo pip install --install-option="--user" virtualenvwrapper
Then I configure bash:
export WORKON_HOME=$HOME/web/proj-env #path to the project's virtual environment
export PROJECT_HOME=$HOME/web/proj # path where the project code will be
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh
Next, I go to the folder with the project code ~/web/proj and, in my opinion, I should already have a virtual environment running, but no, every time after closing the terminal, I need to do mkvirtualenv proj-env. python manage.py runserver doesn't work without this - standard error:
Traceback (most recent call last):
File "manage.py", line 8, in
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
If this is true, then what is the fundamental difference from a simple virtual environment when you need to do source bin/activate ?
By the way, when starting the terminal the message is: "bash: /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh: No such file or directory"
Several times deleted, put - it's still there. There is nothing in the ~/.bashrc file except for the added lines (described by me above)...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
marazmiki, 2015-05-05
@marazmiki

Next, I go to the folder with the project code ~/web/proj and, in my opinion, I should already have a virtual environment running

Shouldn't. Automatic activation of virtual environments is implemented in good solutions, not useless crafts like virtualenvwrapper :-)
As for me, the only plus (although how to see if it's a plus) of virtualenvwrapper is that all virtual environments are stored in one directory.
I consider the model that you essentially described to be much more convenient: when the virtual environment lies directly in the project directory, of course, under gitignor. And when you enter the project directory, the environment is automatically activated. When exiting, respectively, deactivated. Also automatically.
I have been using this approach for more than three years, I am happy as an elephant and sincerely do not understand those who admire virtualenvwrapper.

S
sim3x, 2015-05-05
@sim3x

every time after closing the terminal you need to do

Script Location
locate virtualenvwrapper.sh

B
bromzh, 2015-05-06
@bromzh

echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc

Now when you start the terminal, everything will work.
And you don’t need to export anything separately, you have to install the wrapper itself once, and then make source every time. These are the features of the bash, there is no other way to do it. The lines above are added to the file that starts when the terminal starts with bash, wrapper initialization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question