1👍
Let’s start from the beginning:
- You are in your project folder eg
/home/me/myproject
- You create a new virtualenv, eg
virtualenv /home/me/virtualenvs/myprojectenv
- You activate the new virtualenv:
source /home/me/virtualenvs/myprojectenv/bin/activate
…this means thatpython
andpip
commands now point to the versions installed in your virtualenv - You install your project dependencies
pip install django
- You can
./manage.py runserver
successfully
Now, the virtualenv has only been activated in your current terminal session. If you cd
outside your project directory the virtualenv is still active. But if you open a new terminal window (or turn off the computer and come back later) the virtualenv is not activated.
If the virtualenv is not activated then the python
and pip
commands point to the system-installed copies (if they exist) and Django has not been installed there.
All you need to do when you open a new terminal is step 3. above:
source /home/me/virtualenvs/myprojectenv/bin/activate
Possibly the tutorial you followed got you to install virtualenvwrapper
which is an additional convenience layer around the virtualenv commands above. In that case the steps would look like this:
- You are in your project folder eg
/home/me/myproject
- You create a new virtualenv, eg
mkvirtualenv myprojectenv
…virtualenv has already been activated for you now! - You install your project dependencies
pip install django
- You can
./manage.py runserver
successfully
and whenever you start a new shell session you need to:
workon myprojectenv
in order to re-activate the virtualenv