Installation - symlink vs. python setup.py install

282 views
Skip to first unread message

Greig Rapley

unread,
Dec 3, 2007, 1:17:05 PM12/3/07
to Django users
Hi,

I have django (trunk) installed on MacOSX 10.5 using mod_python and it
all works fine when I use python setup.py install to actually install
the files retrieved via subversion. However if I follow the
installation instructions to use a symlink to my SITE-PACKAGES
directory I get the following traceback;

Traceback (most recent call last):

File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 1202, in _process_target
module = import_module(module_name, path=path)

File "/Library/Python/2.5/site-packages/mod_python/importer.py",
line 304, in import_module
return __import__(module_name, {}, {}, ['*'])

ImportError: No module named django.core.handlers.modpython


Now I assume this is a Python path issue but I don't know what happens
during "python setup.py install" that means my mod_python importer can
find django.core.handler.modpython when it can't find the exact same
file (at the exact same path) after I use a symlink ?

Any help would be greatly appreciated.

Greig


Greig Rapley

unread,
Dec 3, 2007, 1:25:07 PM12/3/07
to Django users
Actually, I have just rerun "python setup.py install" to get my
installation working again and noticed the running install_egg_info
that happens last. Might this have something to do with my problems
when using a symlink instead ?

Graham Dumpleton

unread,
Dec 3, 2007, 4:38:32 PM12/3/07
to Django users
Apache generally runs as a special user. This user must have read
access to those Django modules you have symlinked into the Python site-
packages directory. Thus if the files are not readable to others, or
any of the directories from the root right down to where the Django
software is actually installed are not readable/searchable to others,
then Python running under Apache will fail in being able to import the
modules.

Graham

Greig Rapley

unread,
Dec 4, 2007, 6:29:25 PM12/4/07
to Django users
Unfortunately that hasn't worked. I even tried chown'ing the entire
tree beneath django-trunk, and the symlink itself, to www:www. Still
mod_python says that it cannot import django.core.handlers.modpython.
I have gone through your mod_python mptest exercise again and
everything works fine. Then, I simply run python setup.py install
again, and it all works fine. Any further ideas ? Can I try
importing django modules using mptest ?

Greig


On Dec 3, 9:38 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:

Graham Dumpleton

unread,
Dec 4, 2007, 7:57:25 PM12/4/07
to Django users
On Dec 5, 10:29 am, Greig Rapley <gr...@rapley.co.nz> wrote:
> Unfortunately that hasn't worked. I even tried chown'ing the entire
> tree beneath django-trunk, and the symlink itself, to www:www. Still
> mod_python says that it cannot import django.core.handlers.modpython.
> I have gone through your mod_python mptest exercise again and
> everything works fine. Then, I simply run python setup.py install
> again, and it all works fine. Any further ideas ? Can I try
> importing django modules using mptest ?

Set PythonHandler to mod_python::testhandler and see what sys.path is
actually being set to for a request.

Graham

Graham Dumpleton

unread,
Dec 4, 2007, 8:13:53 PM12/4/07
to Django users
BTW, that it is looking in:

/Library/Python/2.5/site-packages

suggests your mod_python is using MacPorts Python.

Where were you actually symlinking in to?

If you were symlinking into /System/Library/Frameworks/Python/Current/
lib/site-packages it wouldn't find it as it doesn't look there.

Can you just use the OS version of Python 2.5 on MacOS X 10.5 and not
the MacPorts version. I have seen someone else having odd problems
when they tried to install MacPorts 2.5 when the OS already supplied
2.5.

Graham

On Dec 5, 11:57 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:

Greig Rapley

unread,
Dec 5, 2007, 7:01:41 PM12/5/07
to Django users
$ sudo port installed

does not include python in the list returned, so I assume I am using
the OS version.

$ which python
/usr/bin/python

and,

$ python -c "from distutils.sysconfig import get_python_lib; print
get_python_lib()"
/Library/Python/2.5/site-packages

I have been symlinking into /Library/Python/2.5/site-packages.

I have found the *other* site-packages directory, it is;

/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages

but there is only a partial django directory in there;

django/conf
django/contrib

Ok, so I have removed MacPorts following the instructions in the FAQ.

I have installed the testhandler and here are the results;

General information

Apache version Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2
mod_python/3.3.1 Python/2.5.1
Apache threaded MPM No (single thread MPM)
Apache forked MPM Yes, maximum 256 processes
Apache server root /usr
Apache document root /Library/WebServer/Documents
Apache error log /private/var/log/apache2/error_log (view last 100
lines)
Python sys.version 2.5.1 (r251:54863, Oct 5 2007, 21:08:09) [GCC 4.0.1
(Apple Inc. build 5465)]
Python sys.path
/Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-
i386.egg
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python25.zip
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
python
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
lib-dynload
/Library/Python/2.5/site-packages
/Library/Python/2.5/site-packages/PIL
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
python/PyObjC
Python interpreter name main_interpreter
mod_python.publisher available Yes
mod_python.psp available No

which still works without MacPorts.

And;

$ python
Python 2.5.1 (r251:54863, Oct 5 2007, 21:08:09)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django.core.handlers.modpython
>>>

Looks like the same Python from the command line as from within
mod_python, and yet the command line interpreter has no problem
finding django.core.handlers.modpython !

Still hoping I can find a way to symlink instead of installing every
svn update :-)

On Dec 5, 1:13 am, Graham Dumpleton <Graham.Dumple...@gmail.com>

Graham Dumpleton

unread,
Dec 5, 2007, 7:14:06 PM12/5/07
to Django users
Okay, I had a part brain fade there. Was confusing /Library/Frameworks/
Python with /Library/Python. The /Library/Frameworks/Python is what
MacPorts uses.

Also looks like Python 2.5 on Mac OS X 10.5 sets up sys.path
differently, ie., uses shorter /Library/Python/2.5/sites-packages
instead of longer path out of /System/Library/Frameworks/Python.

On Mac OS X 10.4 and Python 2.3 the long path version is just a
symlink to the short path version.

8 lrwxr-xr-x 1 root wheel 56 Jul 13 2006 site-packages -
> ../../../../../../../../Library/Python/2.3/site-packages

Ie., they should effectively be the same directory, yet your comment
about partial Django in long path suggests they aren't, or what you
are symlinking to with the django link isn't correct in the first
place.

I have 10.5 on a firewire drive here so I'll try and boot it up and
see how it links the two directories if it does.

Graham

Graham Dumpleton

unread,
Dec 5, 2007, 8:21:45 PM12/5/07
to Django users
On 10.5 with a virgin Python 2.5 installation there is no:

/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages

If you have it then something has wrongly created it and you probably
should delete the whole directory in case it causes problems.

The Python 2.3 installation on 10.5 still has the site-packages in the
long path location, but as I said, it is a symlink to /Library/Python/
2.3/...

BTW, with all the problems you are having, you might want to look at
mod_wsgi 2.0 instead and use its support for easily pointing at Python
virtual environments created using virtualenv. This way you could have
different virtual environments for different versions of Django and
how applications using the different versions in different daemon
processes using mod_wsgi daemon mode. :-)

Graham

On Dec 6, 11:14 am, Graham Dumpleton <Graham.Dumple...@gmail.com>
Reply all
Reply to author
Forward
0 new messages