Macports and virtualenv site-packages Fallback

Posted by Streeter on Stack Overflow See other posts from Stack Overflow or by Streeter
Published on 2011-01-12T06:49:41Z Indexed on 2011/01/12 6:53 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

I've installed django and python as this link suggested with macports. However, I'd like to use virtualenv to install more packages. My understanding is that if I do not pass in the --no-site-packages to virtualenv, I should get the currently installed packages in addition to whatever packages I install into the virtual environment. Is this correct?

As an example, I've installed django through macports and then create a virtual environment, but I cannot import django from within that virtual environment:

[streeter@mordecai]:~$ mkvirtualenv django-test
New python executable in django-test/bin/python
Installing setuptools............done.
...
(django-test)[streeter@mordecai]:~$ pip install django-debug-toolbar
Downloading/unpacking django-debug-toolbar
  Downloading django-debug-toolbar-0.8.4.tar.gz (80Kb): 80Kb downloaded
  Running setup.py egg_info for package django-debug-toolbar
Installing collected packages: django-debug-toolbar
  Running setup.py install for django-debug-toolbar
Successfully installed django-debug-toolbar
Cleaning up...
(django-test)[streeter@mordecai]:~$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] 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
>>>

So I can install packages into the virtual environment, but it isn't picking up the global site-packages. Or am I not doing something correctly / missing something / misunderstanding how virtualenv works?

I've got Mac OS 10.6 (Snow Leopard), have updated my macports packages and am using macports' python26 (via python_select python26).

© Stack Overflow or respective owner

Related posts about python

Related posts about django