Please use the mod_wsgi mailing list, don't email me directly.

On 9 February 2010 13:24, louisplp <[email protected]> wrote:
> I've got exactly the same problem.

It is not necessarily the same problem.

They had:

  ImportError: No module named paste.deploy

You have:

  ImportError: No module named deploy

The difference is important.

In your case a Python module or Python package root called 'paste' can
be found, but it can't find a submodule within it called 'deploy'.

This can occur for two reasons.

1. You have the actual package, but the permissions of only the top
level directory is correct and all the contents of the directory and
subdirectories have wrong permissions.

2. You have a distinct Python package, module or script of your own
somewhere on your module search path called 'paste.py' and that is
being found by mistake.

Do the following:

  python
  >>> import paste
  >>> print paste.__file__

That will give you location.

If a script file called paste.py, then (2). If a file called
'__init__.py' in a directory called 'paste' then is likely (1), but
could also be (2).

Graham

> All the directories' permissions are right.
> I can't even run the wsgi script direclty with python
>
> $ python dispatch.wsgi
> Traceback (most recent call last):
>  File "dispatch.wsgi", line 15, in <module>
>    from paste.deploy import loadapp
> ImportError: No module named deploy
>
> All the virtualenv lib are first in sys.path
>
> Please help,
>
> Louis
>
> On 3 jan, 02:54, Graham Dumpleton <[email protected]> wrote:
>> 2010/1/3 Todd Blanchard <[email protected]>:
>>
>>
>>
>> > Centos 5.3 at slicehost, TG2.1a3, apache2.  I got mod_wsgi installed
>> > and the simple test wsgi script file works.  Now I'm trying to launch
>> > my TG2 app using avirtualenv.  I've cloned the wsgi file and run it
>> > from the command line and had it dump sys.path and I get
>>
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/setuptools-0.6c11-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/pip-0.6.1-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/tg.devtools-2.1a3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.who-1.0.18-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > repoze.what_quickstart-1.0.3_r6729-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/SQLAlchemy-0.5.6-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > sqlalchemy_migrate-0.5.4-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/TurboGears2-2.1a3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/zope.interface-3.5.2-
>> > py2.6-linux-x86_64.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Paste-1.7.2-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > repoze.who_friendlyform-1.0b3-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > repoze.what.plugins.sql-1.0rc3_r6698-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > repoze.who.plugins.sa-1.0rc2-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.what-1.0.8-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/decorator-3.0.0-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/repoze.tm2-1.0a5-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > repoze.what_pylons-1.0-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebError-0.10.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/ToscaWidgets-0.9.8-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebFlash-0.1a9-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Genshi-0.5.1-py2.6-
>> > linux-x86_64.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Pylons-0.9.7-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > repoze.who_testutil-1.0rc1-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/transaction-1.0.0-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/simplejson-2.0.9-
>> > py2.6-linux-x86_64.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Pygments-1.1.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Tempita-0.4-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebOb-0.9.6.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebTest-1.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Mako-0.2.5-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/nose-0.11.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/FormEncode-1.2.2-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/PasteScript-1.7.3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/PasteDeploy-1.3.3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/WebHelpers-0.6.4-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Routes-1.10.3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Beaker-1.5.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/tgext.geo-0.6-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/TileCache-2.10-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/mapfish-1.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/psycopg2-2.0.13-
>> > py2.6-linux-x86_64.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/GeoAlchemy-0.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/FeatureServer-1.12-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/tgext.admin-0.3.6-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/zope.sqlalchemy-0.4-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Babel-0.9.4-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/tgext.crud-0.3.3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/sprox-0.6.6-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/geojson-1.0.1-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Shapely-1.0.14-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/tw.forms-0.9.8-
>> > py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/
>> > modwsgideploy-0.4.20dev-py2.6.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Cheetah-2.4.1-py2.6-
>> > linux-x86_64.egg
>> > /home/tgdev/spacetime/lib/python2.6/site-packages/Markdown-2.0.3-
>> > py2.6.egg
>> > /home/tgdev/spacetime/eagle
>> > /home/tgdev/spacetime/lib/python2.6/site-packages
>> > /var/www/wsgi-scripts
>> > /opt/python2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
>> > /opt/python2.6/lib/python2.6/site-packages/virtualenv-1.4.3-py2.6.egg
>> > /opt/python2.6/lib/python26.zip
>> > /opt/python2.6/lib/python2.6
>> > /opt/python2.6/lib/python2.6/plat-linux2
>> > /opt/python2.6/lib/python2.6/lib-tk
>> > /opt/python2.6/lib/python2.6/lib-old
>> > /opt/python2.6/lib/python2.6/lib-dynload
>> > /opt/python2.6/lib/python2.6/site-packages
>>
>> > which looks exactly right -virtualenvlibs first, default system libs
>> > last.
>>
>> > My wsgi file looks like:
>>
>> > import os, sys
>>
>> > APP_NAME = 'eagle'
>> > ENV_PATH = '/home/tgdev/spacetime'
>> > APP_PATH = ENV_PATH + '/eagle'
>> > PKG_PATH = ENV_PATH + '/lib/python2.6/site-packages'
>>
>> > prev_sys_path = list(sys.path)
>>
>> > import site
>> > site.addsitedir(APP_PATH)
>> > site.addsitedir(PKG_PATH)
>> > os.environ['PYTHON_EGG_CACHE'] = '/var/tmp/' + APP_NAME + '/python-
>> > eggs'
>>
>> > new_sys_path = []
>> > for item in list(sys.path):
>> >    if item not in prev_sys_path:
>> >        new_sys_path.append(item)
>> >        sys.path.remove(item)
>> > sys.path[:0] = new_sys_path
>>
>> > frompaste.deploy import loadapp
>>
>> > application = loadapp('config:' + APP_PATH + '/development.ini')
>>
>> > and my virtual host config in apache looks like:
>>
>> > WSGIPythonHome /opt/python2.6
>>
>> > <VirtualHost *:80>
>>
>> >    ServerName ***********
>> >    ServerAlias ***************
>> >    ServerAdmin *************
>>
>> >    <Directory /var/www/static/eagle>
>> >    Options Indexes FollowSymLinks
>> >    AllowOverride None
>> >    Order allow,deny
>> >    Allow from all
>> >    </Directory>
>>
>> >    DocumentRoot /var/www/static/eagle
>>
>> >    Alias /robots.txt /var/www/static/eagle/robots.txt
>> >    Alias /favicon.ico /var/www/static/eagle/favicon.ico
>> >    Alias /css/ /var/www/static/eagle/css/
>> >    Alias /images/ /var/www/static/eagle/images/
>> >    Alias /media/ /var/www/static/eagle/media/
>>
>> >    #WSGIDaemonProcess eagle processes=2 threads=15 display-name=%
>> > {GROUP}
>> >    #WSGIProcessGroup eagle
>>
>> >    WSGIScriptAlias / /var/www/wsgi-scripts/eagle.wsgi
>>
>> >    <Directory /var/www/wsgi-scripts>
>> >    Order allow,deny
>> >    Allow from all
>> >    </Directory>
>>
>> > </VirtualHost>
>>
>> > What I see in the error_log is
>>
>> > [Sun Jan 03 05:17:54 2010] [error] [client 71.227.129.215] mod_wsgi
>> > (pid=15568): Target WSGI script '/var/www/wsgi-scripts/eagle.wsgi'
>> > cannot be loaded as Python module.
>> > [Sun Jan 03 05:17:54 2010] [error] [client 71.227.129.215] mod_wsgi
>> > (pid=15568): Exception occurred processing WSGI script '/var/www/wsgi-
>> > scripts/eagle.wsgi'.
>> > [Sun Jan 03 05:17:54 2010] [error] [client 71.227.129.215] Traceback
>> > (most recent call last):
>> > [Sun Jan 03 05:17:54 2010] [error] [client 71.227.129.215]   File "/
>> > var/www/wsgi-scripts/eagle.wsgi", line 22, in <module>
>> > [Sun Jan 03 05:17:54 2010] [error] [client 71.227.129.215]     from
>> >paste.deploy import loadapp
>> > [Sun Jan 03 05:17:54 2010] [error] [client 71.227.129.215]
>> > ImportError: No module namedpaste.deploy
>>
>> > but I do not get that import error if I run the file from the command
>> > line.  What gives?
>>
>> I can only guess that the virtual environment is not readable to the
>> user that Apache runs as.
>>
>> In other words, be aware that Apache runs as a special user. That user
>> must have read/search access on directories and read access to files
>> in the directories. For directories this must be from '/' all the way
>> down to where actual Python code files are. Thus, if /home/tgdev has
>> permissions rwxr-x---, ie. not readable to others, will not be able to
>> read the code files.
>>
>> So, check all your directory/file permissions properly.
>>
>> Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to