ImportError no module named cherrypy

3,629 views
Skip to first unread message

Tiger Uppercut

unread,
Sep 26, 2007, 5:21:44 AM9/26/07
to modwsgi
Hi,

I'm new to mod_wsgi and had a simple question -- I couldn't find this
in the group archives or elsewhere.

I'm getting a simple ImportError -- no module named CherryPy -- when I
try to use the first method cited in this [http://code.google.com/p/
modwsgi/wiki/IntegrationWithTurboGears#whb] article.

{{{

[Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] mod_wsgi
(pid=28107): Target WSGI script '/mnt/local/deploy/tg/apache/tg.wsgi'
cannot be loaded as Python
module.
[Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] mod_wsgi
(pid=28107): Exception occurred within WSGI script '/mnt/local/deploy/
tg/apache/tg.wsgi'.
[Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] Traceback (most
recent call
last):
[Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] File "/mnt/
local/deploy/tg/apache/tg.wsgi", line 18, in <module>
[Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] import
cherrypy
[Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] ImportError: No
module named cherrypy

}}}

My sys.path includes cherrypy:

{{{

['/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/
plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-
dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/
python2.5/site-packages', '/mnt/local/deploy/tg/', '/usr/lib/python2.5/
site-packages/CherryPy-2.2.1-py2.5.egg/cherrypy', '/mnt/local/deploy/
tg/', '/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
cherrypy/']

}}}

And I'm able to import cherrypy normally from the command line:

{{{

$ python
>>> import cherrypy
>>>

}}}

Any clues on where I might be going wrong?

Graham Dumpleton

unread,
Sep 26, 2007, 7:00:04 AM9/26/07
to mod...@googlegroups.com
It should only use:

/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg

in the path. It shouldn't include 'cherrypy' at the end.

Are you adding that into sys.path yourself. By rights you shouldn't
need to if setuptools stuff is all installed correctly as it should
activate when Python startups and automatically add the path itself.

Graham

Tiger Uppercut

unread,
Sep 26, 2007, 12:39:03 PM9/26/07
to mod...@googlegroups.com
Thanks, and apologies that I can't put the code snippets in WikiFormatting.

This path /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg is
in sys.path if I run python normally from the command line. [See
outdented line below.]

$ python
>>> import sys
>>> sys.path

['', '/usr/lib/python2.5/site-packages/TurboGears-1.0.4b1-py2.5.egg',
'/usr/lib/python2.5/site-packages/SQLObject-0.9.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg',
'/usr/lib/python2.5/site-packages/TurboKid-1.0.3-py2.5.egg',
'/usr/lib/python2.5/site-packages/TurboJson-1.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/TurboCheetah-0.9.5-py2.5.egg',
'/usr/lib/python2.5/site-packages/simplejson-1.7.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/RuleDispatch-0.5a0.dev_r2306-py2.5-linux-i686.egg',
'/usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg',
'/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/DecoratorTools-1.5-py2.5.egg',
'/usr/lib/python2.5/site-packages/configobj-4.4.0-py2.5.egg',

'/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg',

'/usr/lib/python2.5/site-packages/Cheetah-2.0rc8-py2.5-linux-i686.egg',
'/usr/lib/python2.5/site-packages/kid-0.9.6-py2.5.egg',
'/usr/lib/python2.5/site-packages/PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg',
'/usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/Paste-1.4.2-py2.5.egg',
'/usr/lib/python2.5/site-packages/Myghty-1.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/Routes-1.7-py2.5.egg',
'/usr/lib/python2.5/site-packages/setuptools-0.6c7-py2.5.egg',
'/usr/lib/python2.5/site-packages/Pylons-0.9.6-py2.5.egg',
'/usr/lib/python2.5/site-packages/buildutils-0.3-py2.5.egg',
'/usr/lib/python2.5/site-packages/pudge-0.1.3-py2.5.egg',
'/usr/lib/python2.5/site-packages/Pygments-0.8.1-py2.5.egg',
'/usr/lib/python2.5/site-packages/elementtree-1.2.6_20050316-py2.5.egg',
'/usr/lib/python2.5/site-packages/docutils-0.4-py2.5.egg',
'/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg',
'/usr/lib/python2.5/site-packages/nose-0.10.0b1-py2.5.egg',
'/usr/lib/python2.5/site-packages/decorator-2.2.0-py2.5.egg',
'/usr/lib/python2.5/site-packages/Beaker-0.7.5-py2.5.egg',
'/usr/lib/python2.5/site-packages/WebHelpers-0.3.2-py2.5.egg',
'/usr/lib/python25.zip', '/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
'/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/var/lib/python-support/python2.5']

So I added a simple debugging statement to my tg.wsgi code:

sys.stdout = sys.stderr
print sys.path

When I examine the error logs, I get a very different starting sys.path:

Apache error.log:

[Wed Sep 26 09:26:00 2007] [error] ['/usr/lib/python25.zip',
'/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages']

I tried manually appending the CherryPy path, in tg.wgsi as:

sys.path.append('/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/')

And this shows up faithfully in the error.log under sys.path

[Wed Sep 26 09:26:00 2007] [error] ['/usr/lib/python25.zip',
'/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages','/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/']

But I still hit the ImportError: no module named cherrypy.

If it helps, I've also pasted my tg.wsgi code below:

-------------

import sys
# Taken from http://code.google.com/p/modwsgi/wiki/IntegrationWithTurboGears

# Need to set this path automatically when we move out from the
repository into the build path
sys.path.append('/mnt/local/deploy/tg')
sys.path.append('/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/')

sys.stdout = sys.stderr
print "------"
print sys.path
import os
os.environ['PYTHON_EGG_CACHE'] = '/mnt/local/deploy/tg/eggs/'

import re
import atexit
import cherrypy
import cherrypy._cpwsgi
import turbogears

turbogears.update_config(configfile="dev.cfg", modulename="tg.config")
turbogears.config.update({'global': {'server.environment': 'production'}})
turbogears.config.update({'global': {'autoreload.on': False}})
turbogears.config.update({'global': {'server.log_to_screen': False}})

if cherrypy.server.state == 0:
atexit.register(cherrypy.server.stop)
cherrypy.server.start(init_only=True, server_class=None)

import tg.controllers

cherrypy.root = tg.controllers.Root()

application = cherrypy._cpwsgi.wsgiApp

Graham Dumpleton

unread,
Sep 26, 2007, 6:53:21 PM9/26/07
to mod...@googlegroups.com
What is in:

/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/

Is it an expanded set of directories or is this a packed egg, ie., single file?

What is in:

/mnt/local/deploy/tg/eggs/

ie., what eggs have been unpacked in there.

Does the user Apache runs as have write permission to the egg cache?

Graham

Tiger Uppercut

unread,
Sep 27, 2007, 12:58:05 AM9/27/07
to mod...@googlegroups.com
> What is in:
>
> /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
>
> Is it an expanded set of directories or is this a packed egg, ie., single file?

It is an expanded set of directories:

$ ls -al /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
total 16
drwxrw-r-x 4 root www-data 4096 Sep 21 22:50 .
drwxrw-r-x 32 root www-data 4096 Sep 26 11:41 ..
drwxrw-r-x 2 root www-data 4096 Sep 21 22:50 EGG-INFO
drwxrw-r-x 6 root www-data 4096 Sep 21 22:50 cherrypy

The Apache user runs as:

User www-data
Group www-data

> What is in:
>
> /mnt/local/deploy/tg/eggs/

Nothing is in this directory -- I thought this was where eggs would be
unpacked at runtime if so needed:

$ ls -al /mnt/local/deploy/tg/eggs

total 8
drwxr-xr-x 2 root www-data 4096 Sep 26 00:58 .
drwxr-xr-x 6 root www-data 4096 Sep 26 00:58 ..

I originally ran into the permissions error -- but after I chown'd -R
root.www-data, that error disappeared and I was left only with the
ImportError.

Thanks,

T.U.

Graham Dumpleton

unread,
Sep 27, 2007, 1:07:39 AM9/27/07
to mod...@googlegroups.com
On 27/09/2007, Tiger Uppercut <get2tha...@gmail.com> wrote:
>
> > What is in:
> >
> > /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
> >
> > Is it an expanded set of directories or is this a packed egg, ie., single file?
>
> It is an expanded set of directories:
>
> $ ls -al /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
> total 16
> drwxrw-r-x 4 root www-data 4096 Sep 21 22:50 .
> drwxrw-r-x 32 root www-data 4096 Sep 26 11:41 ..
> drwxrw-r-x 2 root www-data 4096 Sep 21 22:50 EGG-INFO
> drwxrw-r-x 6 root www-data 4096 Sep 21 22:50 cherrypy

I cant see how it would matter as still o+x, but you don't have g+x on
the directory permissions.

Run:

cd /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg
find . -type d -print -exec chmod 0775 {} \;

This will ensure that g+x is on all directories under that location.

Also ensure that the .py files in the directory hierarchy are sensible as well.

> The Apache user runs as:
>
> User www-data
> Group www-data
>
> > What is in:
> >
> > /mnt/local/deploy/tg/eggs/
>
> Nothing is in this directory -- I thought this was where eggs would be
> unpacked at runtime if so needed:
>
> $ ls -al /mnt/local/deploy/tg/eggs
>
> total 8
> drwxr-xr-x 2 root www-data 4096 Sep 26 00:58 .
> drwxr-xr-x 6 root www-data 4096 Sep 26 00:58 ..
>
> I originally ran into the permissions error -- but after I chown'd -R
> root.www-data, that error disappeared and I was left only with the
> ImportError.

That shouldn't have been required on the Python site-packages
directory unless the directory permissions were screwed up in the
first place such that they weren't readable to others. In general you
shouldn't be changing ownership of stuff in Python site-packages at
all.

Graham

Tiger Uppercut

unread,
Oct 17, 2007, 4:28:00 AM10/17/07
to mod...@googlegroups.com
Just wanted to follow-up here, any tips on this?

I'm still getting the same error [from my apache error logs]:

[Wed Oct 17 01:20:18 2007] [error] [client xx.yy.zz.aa] mod_wsgi
(pid=8063): Target WSGI script '/mnt/local/deploy/tg/apache/tg.wsgi'


cannot be loaded as Python module.

[Wed Oct 17 01:20:18 2007] [error] [client xx.yy.zz.aa] mod_wsgi
(pid=8063): Exception occurred within WSGI script
'/mnt/local/deploy/tg/apache/tg.wsgi'.
[Wed Oct 17 01:20:18 2007] [error] [client xx.yy.zz.aa] Traceback
(most recent call last):
[Wed Oct 17 01:20:18 2007] [error] [client xx.yy.zz.aa] File
"/mnt/local/deploy/tg/apache/tg.wsgi", line 18, in <module>
[Wed Oct 17 01:20:18 2007] [error] [client xx.yy.zz.aa] import
cherrypy
[Wed Oct 17 01:20:18 2007] [error] [client xx.yy.zz.aa] ImportError:
No module named cherrypy

The permissions on the directory /mnt/local/deploy/tg/eggs:

drwxr-xr-x 2 root www-data 4096 Oct 17 00:52 eggs

The permissions on the directory /mnt/local/deploy/tg/apache:

drwxr-xr-x 2 root www-data 4096 Oct 17 01:03 apache

And on the cherryPy directory:

drwxrw-r-x 4 root www-data 4096 Sep 21 22:50 CherryPy-2.2.1-py2.5.egg

Thanks again - seems pretty simple, but I can't seem to track it down,
so I appreciate your help!

Tiger Uppercut

unread,
Oct 17, 2007, 4:41:02 AM10/17/07
to modwsgi
I apologize - I didn't seen Graham's email dated 9/27/2007 -- it
appears online in the googlegroup, but I didn't see the reply in my
inbox.

However, I implemented this suggestion in the CherryPy dir:

$ find . -type d -print -exec chmod 0775 {} \;
$ ls -al
drwxrwxr-x 4 root www-data 4096 Sep 21 22:50 .
drwxrw-r-x 32 root www-data 4096 Sep 28 17:49 ..
drwxrwxr-x 2 root www-data 4096 Sep 21 22:50 EGG-INFO
drwxrwxr-x 6 root www-data 4096 Sep 21 22:50 cherrypy

but I'm still getting the same permissions error:

[Wed Oct 17 01:36:38 2007] [error] [client xx.yy.zz.aa] File "/mnt/
local/deploy/tg/apache/tg.wsgi", line 20, in <module>
[Wed Oct 17 01:36:38 2007] [error] [client xx.yy.zz.aa] import
cherrypy
[Wed Oct 17 01:36:38 2007] [error] [client xx.yy.zz.aa] ImportError:
No module named cherrypy

Thanks - and apologies for missing your earlier post.

> > On 9/26/07, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
>
> > > What is in:
>
> > > /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
>
> > > Is it an expanded set of directories or is this a packed egg, ie., single file?
>
> > > What is in:
>
> > > /mnt/local/deploy/tg/eggs/
>
> > > ie., what eggs have been unpacked in there.
>
> > > Does the user Apache runs as have write permission to the egg cache?
>
> > > Graham
>

> > > On 27/09/2007, Tiger Uppercut <get2thachop...@gmail.com> wrote:
>
> > > > Thanks, and apologies that I can't put the code snippets in WikiFormatting.
>
> > > > This path /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg is
> > > > in sys.path if I run python normally from the command line. [See
> > > > outdented line below.]
>
> > > > $ python
> > > > >>> import sys
> > > > >>> sys.path
>
> > > > ['', '/usr/lib/python2.5/site-packages/TurboGears-1.0.4b1-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/SQLObject-0.9.1-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/TurboKid-1.0.3-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/TurboJson-1.1-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/TurboCheetah-0.9.5-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/simplejson-1.7.1-py2.5.egg',

> > > > '/usr/lib/python2.5/site-packages/RuleDispatch-0.5a0.dev_r2306-py2.5-linux- i686.egg',


> > > > '/usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/DecoratorTools-1.5-py2.5.egg',
> > > > '/usr/lib/python2.5/site-packages/configobj-4.4.0-py2.5.egg',
>
> > > > '/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg',
>
> > > > '/usr/lib/python2.5/site-packages/Cheetah-2.0rc8-py2.5-linux-i686.egg',
> > > > '/usr/lib/python2.5/site-packages/kid-0.9.6-py2.5.egg',

> > > > '/usr/lib/python2.5/site-packages/PyProtocols-1.0a0dev_r2302-py2.5-linux-i6 86.egg',

> > > > # Taken fromhttp://code.google.com/p/modwsgi/wiki/IntegrationWithTurboGears


>
> > > > # Need to set this path automatically when we move out from the
> > > > repository into the build path
> > > > sys.path.append('/mnt/local/deploy/tg')
> > > > sys.path.append('/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/ ')
>
> > > > sys.stdout = sys.stderr
> > > > print "------"
> > > > print sys.path
> > > > import os
> > > > os.environ['PYTHON_EGG_CACHE'] = '/mnt/local/deploy/tg/eggs/'
>
> > > > import re
> > > > import atexit
> > > > import cherrypy
> > > > import cherrypy._cpwsgi
> > > > import turbogears
>
> > > > turbogears.update_config(configfile="dev.cfg", modulename="tg.config")
> > > > turbogears.config.update({'global': {'server.environment': 'production'}})
> > > > turbogears.config.update({'global': {'autoreload.on': False}})
> > > > turbogears.config.update({'global': {'server.log_to_screen': False}})
>
> > > > if cherrypy.server.state == 0:
> > > > atexit.register(cherrypy.server.stop)
> > > > cherrypy.server.start(init_only=True, server_class=None)
>
> > > > import tg.controllers
>
> > > > cherrypy.root = tg.controllers.Root()
>
> > > > application = cherrypy._cpwsgi.wsgiApp
>

> > > > On 9/26/07, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
>
> > > > > It should only use:
>
> > > > > /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg
>
> > > > > in the path. It shouldn't include 'cherrypy' at the end.
>
> > > > > Are you adding that into sys.path yourself. By rights you shouldn't
> > > > > need to if setuptools stuff is all installed correctly as it should
> > > > > activate when Python startups and automatically add the path itself.
>
> > > > > Graham
>

> > > > > On 26/09/2007, Tiger Uppercut <get2thachop...@gmail.com> wrote:
>
> > > > > > Hi,
>
> > > > > > I'm new to mod_wsgi and had a simple question -- I couldn't find this
> > > > > > in the group archives or elsewhere.
>
> > > > > > I'm getting a simple ImportError -- no module named CherryPy -- when I
> > > > > > try to use the first method cited in this [http://code.google.com/p/
> > > > > > modwsgi/wiki/IntegrationWithTurboGears#whb] article.
>
> > > > > > {{{
>
> > > > > > [Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] mod_wsgi
> > > > > > (pid=28107): Target WSGI script '/mnt/local/deploy/tg/apache/tg.wsgi'
> > > > > > cannot be loaded as Python
> > > > > > module.
> > > > > > [Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] mod_wsgi
> > > > > > (pid=28107): Exception occurred within WSGI script '/mnt/local/deploy/
> > > > > > tg/apache/tg.wsgi'.
> > > > > > [Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] Traceback (most
> > > > > > recent call
> > > > > > last):
> > > > > > [Wed Sep 26 02:02:05 2007] [error] [client xx.xx.xx.x] File "/mnt/
> > > > > > local/deploy/tg/apache/tg.wsgi", line 18, in <module>
>

> ...
>
> read more »

Graham Dumpleton

unread,
Oct 17, 2007, 6:12:23 AM10/17/07
to mod...@googlegroups.com
Go:

cd /usr/lib/python2.5/site-packages
ls -lasg

Post the output.

Also do:

cat setuptools.pth

and post the output.

Your site-packages directory must be screwed up in some way, with
permissions wrong such that Apache user can read something important.

The only other possibility is that you have SELinux extensions enabled
and it is stuffing things up.

Graham

Graham Dumpleton

unread,
Oct 17, 2007, 6:14:52 AM10/17/07
to mod...@googlegroups.com
On 17/10/2007, Graham Dumpleton <graham.d...@gmail.com> wrote:
> Go:
>
> cd /usr/lib/python2.5/site-packages
> ls -lasg
>
> Post the output.
>
> Also do:
>
> cat setuptools.pth
>
> and post the output.

Also the output of:

cat easy-install.pth

Graham

Tiger Uppercut

unread,
Oct 17, 2007, 4:03:12 PM10/17/07
to mod...@googlegroups.com
See below for the output of each command:

$ cd /usr/lib/python2.5/site-packages
$ ls -lasg

total 1492                                                                                                                                                                                                                                                                                                                                                                                                                           
  4 drwxrw-r-x 32 www-data   4096 Oct 17 02:07 .
 12 drwxr-xr-x 23 root      12288 Sep 21 23:16 ..                                                                                                                                                                                                                                                                                                                                                                                    
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 Beaker-0.7.5-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:55 Cheetah-2.0rc8-py2.5-linux-i686.egg                                                                                                                                                                                                                                                                                                                                                   
  4 drwxrwxr-x  4 www-data   4096 Sep 21 22:50 CherryPy-2.2.1-py2.5.egg
 28 -rw-rw-r-x  1 www-data  24871 Sep 21 22:50 DecoratorTools-1.5-py2.5.egg                                                                                                                                                                                                                                                                                                                                                          
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 FormEncode-0.7.1-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 Mako-0.1.8-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                  
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:58 Myghty-1.1-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:55 Paste-1.4.2-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                 
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:55 PasteDeploy-1.3.1-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 PasteScript-1.3.6-py2.5.egg                                                                                                                                                                                                                                                                                                                                                           
156 -rw-rw-r-x  1 www-data 151856 Sep 21 22:55 PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg
  4 drwxr--r-x  3 www-data   4096 Sep 26 00:25 PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg-tmp                                                                                                                                                                                                                                                                                                                                   
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 Pygments-0.8.1-py2.5.egg
  4 drwxrw-r-x  5 www-data   4096 Sep 21 23:31 Pylons-0.9.6-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                
  4 -rw-rw-r-x  1 www-data    119 May  2 09:56 README
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:58 Routes-1.7-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                  
212 -rw-rw-r-x  1 www-data 212094 Sep 21 22:50 RuleDispatch-0.5a0.dev_r2306-py2.5-linux-i686.egg
  4 drwxr--r-x  3 www-data   4096 Sep 26 00:25 RuleDispatch-0.5a0.dev_r2306-py2.5-linux-i686.egg-tmp                                                                                                                                                                                                                                                                                                                                 
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 SQLAlchemy-0.3.10-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 SQLObject-0.9.1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                             
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 TurboCheetah-0.9.5-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:54 TurboGears-1.0.4b1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                          
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 TurboJson-1.1-py2.5.egg
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:50 TurboKid-1.0.3-py2.5.egg                                                                                                                                                                                                                                                                                                                                                              
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 WebHelpers-0.3.2-py2.5.egg
  4 lrwxrwxrwx  1 root         68 Sep 28 17:49 aotcompile.py -> /usr/share/pycentral/java-gcj-compat-dev/site-packages/aotcompile.py                                                                                                                                                                                                                                                                                                 
 16 -rw-r--r--  1 root      15166 Sep 28 17:49 aotcompile.pyc
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 buildutils-0.3-py2.5.egg                                                                                                                                                                                                                                                                                                                                                              
  4 lrwxrwxrwx  1 root         67 Sep 28 17:49 classfile.py -> /usr/share/pycentral/java-gcj-compat-dev/site-packages/classfile.py
 12 -rw-r--r--  1 root       8521 Sep 28 17:49 classfile.pyc                                                                                                                                                                                                                                                                                                                                                                         
 68 -rw-rw-r-x  1 www-data  65088 Sep 21 22:50 configobj-4.4.0-py2.5.egg
  8 -rw-rw-r-x  1 www-data   5712 Mar 24  2007 debconf.py                                                                                                                                                                                                                                                                                                                                                                            
  8 -rw-rw-r-x  1 www-data   5836 Sep 21 22:10 debconf.pyc
  8 -rw-rw-r-x  1 www-data   5708 Sep 21 23:31 decorator-2.2.0-py2.5.egg                                                                                                                                                                                                                                                                                                                                                             
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 docutils-0.4-py2.5.egg
  4 -rw-rw-r-x  1 www-data   1121 Sep 21 23:31 easy-install.pth                                                                                                                                                                                                                                                                                                                                                                      
 56 -rw-rw-r-x  1 www-data  51530 Sep 21 23:31 elementtree-1.2.6_20050316-py2.5.egg
  4 lrwxrwxrwx  1 root         92 Sep 28 17:49 java_gcj_compat-1.0.65-py2.5.egg-info -> /usr/share/pycentral/java-gcj-compat-dev/site-packages/java_gcj_compat- 1.0.65-py2.5.egg-info                                                                                                                                                                                                                                                 
  4 drwxrw-r-x  4 www-data   4096 Sep 21 22:55 kid-0.9.6-py2.5.egg
  4 drwxr-xr-x  2 root       4096 Oct 17 02:07 mod_python                                                                                                                                                                                                                                                                                                                                                                            
  4 lrwxrwxrwx  1 root         89 Oct 17 02:07 mod_python-3.2.10-py2.5.egg-info -> /usr/share/pycentral/libapache2-mod-python/site-packages/mod_python-3.2.10-py2.5.egg-info
  8 -rw-r--r--  1 root       6620 Sep 26 11:41 modpython_gateway.py                                                                                                                                                                                                                                                                                                                                                                  
  4 drwxrw-r-x  5 www-data   4096 Sep 21 22:42 mx
  4 drwxrw-r-x  5 www-data   4096 Sep 21 23:31 nose-0.10.0b1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                               
  4 drwxrw-r-x  2 www-data   4096 Sep 21 22:42 psycopg2
  4 lrwxrwxrwx  1 www-data     68 Sep 21 22:42 psycopg2.egg-info -> /usr/share/pycentral/python-psycopg2/site-packages/psycopg2.egg-info                                                                                                                                                                                                                                                                                             
 56 -rw-rw-r-x  1 www-data  52348 Feb 20  2007 psycopgmodule.so
  4 drwxrw-r-x  4 www-data   4096 Sep 21 23:31 pudge-0.1.3-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                 
  4 lrwxrwxrwx  1 www-data     75 Sep 21 23:16 pysqlite-2.3.2.egg-info -> /usr/share/pycentral/python-pysqlite2/site-packages/pysqlite-2.3.2.egg-info
  4 drwxrw-r-x  2 www-data   4096 Sep 21 23:16 pysqlite2                                                                                                                                                                                                                                                                                                                                                                             
  0 lrwxrwxrwx  1 www-data     39 Sep 25 16:08 python-support.pth -> /var/lib/python-support/python2.5/.path
320 -rw-rw-r-x  1 www-data 322095 Sep 21 22:49 setuptools-0.6c6-py2.5.egg                                                                                                                                                                                                                                                                                                                                                            
320 -rw-rw-r-x  1 www-data 322831 Sep 21 23:30 setuptools-0.6c7-py2.5.egg
  4 -rw-rw-r-x  1 www-data     29 Sep 21 23:30 setuptools.pth                                                                                                                                                                                                                                                                                                                                                                        
 44 -rw-rw-r-x  1 www-data  41161 Sep 21 22:50 simplejson-1.7.1-py2.5.egg


$ cat setuptools.pth
./setuptools-0.6c7-py2.5.egg

$ cat easy-install.pth

import sys; sys.__plen = len(sys.path)
./TurboGears-1.0.4b1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                       
./SQLObject-0.9.1-py2.5.egg
./SQLAlchemy-0.3.10-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                        
./TurboKid-1.0.3-py2.5.egg
./TurboJson-1.1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                            
./TurboCheetah-0.9.5-py2.5.egg
./simplejson-1.7.1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                         
./RuleDispatch-0.5a0.dev_r2306-py2.5-linux-i686.egg
./PasteScript-1.3.6-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                        
./FormEncode-0.7.1-py2.5.egg
./DecoratorTools-1.5-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                       
./configobj-4.4.0-py2.5.egg
./CherryPy-2.2.1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                           
./Cheetah-2.0rc8-py2.5-linux-i686.egg
./kid-0.9.6-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                                
./PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg
./PasteDeploy-1.3.1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                        
./Paste-1.4.2-py2.5.egg
./Myghty-1.1-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                               
./Routes-1.7-py2.5.egg
./setuptools-0.6c7-py2.5.egg                                                                                                                                                                                                                                                                                                                                                                                                         
./Pylons-0.9.6-py2.5.egg
./buildutils-0.3-py2.5.egg
./pudge-0.1.3-py2.5.egg
./Pygments-0.8.1-py2.5.egg
./elementtree-1.2.6_20050316-py2.5.egg
./docutils-0.4-py2.5.egg
./Mako-0.1.8-py2.5.egg
./nose- 0.10.0b1-py2.5.egg
./decorator-2.2.0-py2.5.egg
./Beaker-0.7.5-py2.5.egg
./WebHelpers-0.3.2-py2.5.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path [p:p]=new; sys.__egginsert = p+len(new)





> > > > > > ['', '/usr/lib/python2.5/site-packages/TurboGears- 1.0.4b1-py2.5.egg',

> > > > > > '/usr/lib/python2.5/site-packages/SQLObject-0.9.1-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg ',
> > > > > > '/usr/lib/python2.5/site-packages/TurboKid-1.0.3-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/TurboJson-1.1-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/TurboCheetah- 0.9.5-py2.5.egg',

> > > > > > '/usr/lib/python2.5/site-packages/simplejson-1.7.1-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/RuleDispatch-0.5a0.dev_r2306-py2.5-linux- i686.egg',
> > > > > > '/usr/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/DecoratorTools-1.5-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/configobj-4.4.0-py2.5.egg',
> > >
> > > > > > '/usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg',
> > >
> > > > > > '/usr/lib/python2.5/site-packages/Cheetah-2.0rc8-py2.5-linux-i686.egg ',
> > > > > > '/usr/lib/python2.5/site-packages/kid-0.9.6-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/PyProtocols-1.0a0dev_r2302-py2.5-linux-i6 86.egg ',
> > > > > > '/usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/Paste-1.4.2-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/Myghty- 1.1-py2.5.egg',

> > > > > > '/usr/lib/python2.5/site-packages/Routes-1.7-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/setuptools-0.6c7-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/Pylons-0.9.6-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/buildutils-0.3-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/pudge- 0.1.3-py2.5.egg',

> > > > > > '/usr/lib/python2.5/site-packages/Pygments-0.8.1-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/elementtree-1.2.6_20050316-py2.5.egg ',
> > > > > > '/usr/lib/python2.5/site-packages/docutils-0.4-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/Mako-0.1.8-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/nose- 0.10.0b1-py2.5.egg',

> > > > > > '/usr/lib/python2.5/site-packages/decorator-2.2.0-py2.5.egg',
> > > > > > '/usr/lib/python2.5/site-packages/Beaker-0.7.5-py2.5.egg ',
> > > > > > '/usr/lib/python2.5/site-packages/WebHelpers-0.3.2-py2.5.egg',
> > > > > > '/usr/lib/python25.zip', '/usr/lib/python2.5',
> > > > > > '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
> > > > > > '/usr/lib/python2.5/lib-dynload',
> > > > > > '/usr/local/lib/python2.5/site-packages',
> > > > > > '/usr/lib/python2.5/site-packages',
> > > > > > '/var/lib/python-support/python2.5']
> > >
> > > > > > So I added a simple debugging statement to my tg.wsgi code:
> > >
> > > > > > sys.stdout = sys.stderr
> > > > > > print sys.path
> > >
> > > > > > When I examine the error logs, I get a very different starting sys.path:
> > >
> > > > > > Apache error.log:
> > >
> > > > > > [Wed Sep 26 09:26:00 2007] [error] ['/usr/lib/python25.zip',
> > > > > > '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
> > > > > > '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
> > > > > > '/usr/local/lib/python2.5/site-packages',
> > > > > > '/usr/lib/python2.5/site-packages']
> > >
> > > > > > I tried manually appending the CherryPy path, in tg.wgsi as:
> > >
> > > > > > sys.path.append('/usr/lib/python2.5/site-packages/CherryPy- 2.2.1-py2.5.egg/ ')

> > >
> > > > > > And this shows up faithfully in the error.log under sys.path
> > >
> > > > > > [Wed Sep 26 09:26:00 2007] [error] ['/usr/lib/python25.zip',
> > > > > > '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2',
> > > > > > '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload',
> > > > > > '/usr/local/lib/python2.5/site-packages',
> > > > > > '/usr/lib/python2.5/site-packages','/usr/lib/python2.5/site-packages/Cherry Py-2.2.1-py2.5.egg/']
> > >
> > > > > > But I still hit the ImportError: no module named cherrypy.
> > >
> > > > > > If it helps, I've also pasted my tg.wsgi code below:
> > >
> > > > > > -------------
> > >
> > > > > > import sys
> > > > > > # Taken fromhttp://code.google.com/p/modwsgi/wiki/IntegrationWithTurboGears
> > >
> > > > > > # Need to set this path automatically when we move out from the
> > > > > > repository into the build path
> > > > > > sys.path.append ('/mnt/local/deploy/tg')

Graham Dumpleton

unread,
Oct 17, 2007, 6:30:04 PM10/17/07
to mod...@googlegroups.com
You have really mucked up the permissions on your Python installation,
but possibly should still be okay. You might though want to consider
uninstalling your Python installation, manually removing any residuals
in site-packages, delete Python lib directory and then reinstall
everything. This time don't go manually change permissions and
ownership on things if you are unsure about what you are doing.

BTW, are you setting PYTHON_EGG_CACHE environment variable in WSGI
script file as described in documentation for mod_wsgi? This would be
needed as some of your eggs aren't unpacked. The directory you denote
by the variable must be writable to the Apache user.

Graham

> ...
>
> [Message clipped]

Reply all
Reply to author
Forward
0 new messages