Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenv not using own packages

I'm starting to use virtualenv and virtualenvwrapper on my projects.

After activating the virtualenv with the workon command, i installed the following packages with pip install -U <package>:

$ lssitepackages 
django               pip
Django-1.3-py2.7.egg-info    pip-1.0.1-py2.7.egg-info
easy-install.pth         setuptools-0.6c11-py2.7.egg
fabric               setuptools.pth
Fabric-1.0.1-py2.7.egg-info  south
geopy                South-0.7.3-py2.7.egg-info
geopy-0.94.1-py2.7.egg-info

The problem here is (running commands with the virtualenv activated):

$ whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.7 /etc/python2.6 /etc/python /etc/python2.7 /usr/lib/python2.6 /usr/lib/python2.7 /usr/lib64/python2.6 /usr/lib64/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz

$ whereis django-admin
django-admin: /usr/bin/django-admin /usr/local/bin/django-admin.py /usr/share/man/man1/django-admin.1.gz

$ whereis fab
fab: /usr/local/bin/fab

My virtualenv it's not using the local packages!

How do I force the virtualenv use local Python and local version of packges instead my machine packages?


Update - Possible solution

I created a new virtualenv with mkvirtualenv --no-site-packages <name> and now I got these outputs:

$ which python
/home/user/.virtualenvs/VIRTUALENVNAME/bin/python

$ which django-admin
/usr/bin/django-admin

$ which django-admin.py 
/home/user/.virtualenvs/VIRTUALENVNAME/bin/django-admin.py

$ which fab
/home/user/.virtualenvs/VIRTUALENVNAME/bin/fab

Sounds like it's working now... except for the "django-admin" command.

like image 828
Thiago Belem Avatar asked Feb 23 '23 22:02

Thiago Belem


1 Answers

try install the virtualenv using:

mkvirtualenv --no-site-packages

to create the virtualenv without any external python libraries

like image 183
Timmy O'Mahony Avatar answered Feb 26 '23 20:02

Timmy O'Mahony