Forums

what newbie mistake am I making? unable to use a .pth file to reach "south" package from a virtual env

I setup a virtual environment for django15. Just recently I use a .pth is the virtual site-packages folder to reach the system PIL package.

Today I tried to follow the same procedure to make a .pth for the "south" package.

And it does not friggin' work!

my PIL.pth file is in:

~/.virtualenvs/django15/lib/python2.7/site-packages

and contains:

/usr/local/lib/python2.7/site-packages/PIL/

And it works.

my new south.pth file in the same folder contains:

/usr/local/lib/python2.7/site-packages/south/

Both are only one line long - no line ending making a blank line 2.

Here is an listing of the site-packages folder:

(django15)20:25 ~/.virtualenvs/django15/lib/python2.7/site-packages $ ll
total 448
drwxrwxr-x 8 rcooke 4096 Mar 19 20:22 .
drwxrwxr-x 4 rcooke 4096 Mar 15 15:32 ..
drwxrwxr-x 2 rcooke 112 Mar 15 15:35 Django-1.5-py2.7.egg-info
drwxrwxr-x 17 rcooke 4096 Mar 15 15:34 django
-rw-rw-r-- 1 rcooke 60030 Mar 17 19:51 django_contacts-0.5-py2.7.egg
drwxrwxr-x 14 rcooke 4096 Mar 18 16:40 django_extensions
drwxrwxr-x 2 rcooke 131 Mar 18 16:40 django_extensions-1.1.1-py2.7.egg-info
-rw-rw-r-- 1 rcooke 269 Mar 17 19:51 easy-install.pth
-rw-rw-r-- 1 rcooke 44 Mar 18 00:49 pil.pth
drwxrwxr-x 4 rcooke 31 Mar 15 15:32 pip-1.2.1-py2.7.egg
-rw-r--r-- 1 rcooke 332005 Mar 6 10:07 setuptools-0.6c11-py2.7.egg
-rw-rw-r-- 1 rcooke 30 Mar 17 19:51 setuptools.pth
drwxrwxr-x 2 rcooke 112 Mar 18 16:40 six-1.2.0-py2.7.egg-info
-rw-rw-r-- 1 rcooke 10504 Mar 18 16:40 six.py
-rw-rw-r-- 1 rcooke 14020 Mar 18 16:40 six.pyc
-rw-rw-r-- 1 rcooke 46 Mar 19 20:22 south.pth
(django15)20:27 ~/.virtualenvs/django15/lib/python2.7/site-packages $

I'm starting to dig into the reference manual for import in case I'm missing something. But figured I should post here to hedge my bets....

Thanks in advance!

The PIL folder in the system site-packages has another folder called PIL in it. South doesn't. So I putting this

/usr/local/lib/python2.7/site-packages

into south.pth and that seemed to work.

Hah! Thanks Glenn!

I just figured out the same thing thanks to this note:

Note again that python paths point not to the modules themselves, but to their parent directories!

on this page:

http://djangotricks.blogspot.ca/2008/09/note-on-python-paths.html

I just changed my south.pth file to end it at the site-packages folder.

But now how much danger am I in to import the SYSTEM wide version of Django and not the one I have in my virtual env?

There is a slight danger, but it's not large because the path from south.pth is at the end of the sys.path list. So you could have a case where you import something that doesn't exist in the new Django, but does exist in the old one. Then, instead of an import error, you might get some weird behaviour.