Reputation:
I have installed Django within a virtual environment but when I call the package, it doesn't show up.
$ pip install django
Downloading/unpacking django
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
How do I find my Django install within my virtual environment?
Upvotes: 1
Views: 3108
Reputation: 10305
virtualenv
extends/overrides your system python environment with it's paths prepended to the paths of the system python installation.You see, you .virtualenv
site-packages are listed before the system site-packages
, that's how it works.
The thing you have to keep in mind that activate patches your current command line environment, so you must run activate
before running python code depending on your virtualenv
.
Updated:
The workaround is .. !
simon@ri-desktop:~$ mkdir test
simon@ri-desktop:~$ cd test/
simon@ri-desktop:~/test$ ls
simon@ri-desktop:~/test$ virtualenv env
New python executable in env/bin/python
Installing setuptools, pip...done.
simon@ri-desktop:~/test$ ls
env
simon@ri-desktop:~/test$ source env/bin/activate
(env)simon@ri-desktop:~/test$ ls
env
(env)simon@ri-desktop:~/test$ mkdir project
(env)simon@ri-desktop:~/test$ ls
env project
(env)simon@ri-desktop:~/test$ cd project/
(env)simon@ri-desktop:~/test/project$
Upvotes: 1