python egg cache setup

58 views
Skip to first unread message

Hang-A

unread,
Nov 29, 2009, 6:16:32 AM11/29/09
to modwsgi
Hi, list!

I am installing a wsgi application on Red Hat Linux.
My current configuration is apach 2.2 + mod_wsgi 3.0 + python 2.4.
My problem is that egg cache environmental variable does not work,
even though I think I set it up right.
The following is error message I'm getting:
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=3416): Target WSGI script '/var/www/wsgi-bin/dtm_app/
dtm_test_app.wsgi' cannot be loaded as Python module.
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=3416): Exception occurred processing WSGI script '/var/www/wsgi-
bin/dtm_app/dtm_test_app.wsgi'.
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "/var/www/
wsgi-bin/dtm_app/dtm_test_app.wsgi", line 10, in ?
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] import
webapp, simplejson
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "build/
bdist.linux-i686/egg/simplejson/__init__.py", line 108, in ?
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "build/
bdist.linux-i686/egg/simplejson/decoder.py", line 7, in ?
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "build/
bdist.linux-i686/egg/simplejson/scanner.py", line 5, in ?
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "build/
bdist.linux-i686/egg/simplejson/_speedups.py", line 7, in ?
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "build/
bdist.linux-i686/egg/simplejson/_speedups.py", line 4, in
__bootstrap__
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "/usr/lib/
python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py",
line 881, in resource_filename
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] return
get_provider(package_or_requirement).get_resource_filename(
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "/usr/lib/
python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py",
line 1351, in get_resource_filename
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
self._extract_resource(manager, self._eager_to_zip(name))
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "/usr/lib/
python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py",
line 1372, in _extract_resource
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] real_path =
manager.get_cache_path(
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "/usr/lib/
python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py",
line 962, in get_cache_path
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
self.extraction_error()
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] File "/usr/lib/
python2.4/site-packages/setuptools-0.6c11-py2.4.egg/pkg_resources.py",
line 928, in extraction_error
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] raise err
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] ExtractionError:
Can't extract file(s) to egg cache
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] The following
error occurred while trying to extract file(s) to the Python egg
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] cache:
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] [Errno 17]
File exists: '/egg_cache'
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] The Python egg
cache directory is currently set to:
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] /egg_cache/
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1]
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] Perhaps your
account does not have write access to this directory? You can
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] change the cache
directory by setting the PYTHON_EGG_CACHE environment
[Sun Nov 29 04:07:04 2009] [error] [client 127.0.0.1] variable to
point to an accessible directory.

One thing that is different from typical errors is that Error no is
not 13 but 17,
which I cannot make sense of.
The directory /egg_cache is owned by apache (user account that Apache
runs as) so that it can write in that directory.
With the same application I had no problem in Mac Leopard, but I now
have in Red Hat linux.
Any comments are welcome. Thanks in advance.

from Myunghwa Hwang

Clodoaldo Neto

unread,
Nov 29, 2009, 8:52:19 AM11/29/09
to mod...@googlegroups.com
2009/11/29 Hang-A <mhw...@gmail.com>:
Just a workaround while you wait for an answer.

I had this same problem with simplejson installed from the repo in
Centos a while ago. Being devoid of patience to investigate I just
removed the repo install and installed with easy_install and it
worked.

Regards, Clodoaldo

>
> from Myunghwa Hwang
>
> --
>
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>
>
>

Hang-A

unread,
Nov 29, 2009, 4:49:00 PM11/29/09
to modwsgi
Thanks for your hint, Clodoaldo!
Though I am not sure of what the repo is (I am new to linux and
installed simplejson from source code),
I will try to reinstall simplejson with easy_install.

On Nov 29, 6:52 am, Clodoaldo Neto <clodoaldo.pi...@gmail.com> wrote:
> 2009/11/29 Hang-A <mhwa...@gmail.com>:

Graham Dumpleton

unread,
Nov 29, 2009, 5:05:25 PM11/29/09
to mod...@googlegroups.com
How are you configuring the location of the Python EGG cache. Are you using:

1. WSGIPythonEggs directive? Which means you MUST be using embedded mode.

2. Setting python-eggs option to WSGIDaemonProcess? Which means you
MUST be using daemon mode and application must be properly delegated
to that daemon mode process.

3. Setting PYTHON_EGG_CACHE in os.environ in WSGI script file?

4. Some other way?

You need to provide more information about your configuration. Right
now, you aren't using the correct way of setting Python egg cache for
how you are running your application.

Graham

2009/11/29 Hang-A <mhw...@gmail.com>:

Hang-A

unread,
Nov 29, 2009, 5:40:30 PM11/29/09
to modwsgi
I am using mod_wsgi in embedded mode.
And #3 is my current configuration option.
My application code starts as follows:

import os, sys
os.environ['PYTHON_EGG_CACHE'] = '/egg_cache'
abspath = os.path.dirname(__file__)
sys.path.append(abspath)
os.chdir(abspath)

import webapp, simplejson
...

I will continue to using the embedded mode.
How different are your #1 and #2?

By the way, Clodoaldo, after reinstalling simplejson with
easy_install,
now I am getting the following error:
mod_wsgi (pid=2955): Target WSGI script '/var/www/wsgi-bin/dtm_app/
dtm_test_app.wsgi' cannot be loaded as Python module.
[Sun Nov 29 15:38:11 2009] [error] [client 127.0.0.1] mod_wsgi
(pid=2955): Exception occurred processing WSGI script '/var/www/wsgi-
bin/dtm_app/dtm_test_app.wsgi'.
[Sun Nov 29 15:38:11 2009] [error] [client 127.0.0.1] Traceback (most
recent call last):
[Sun Nov 29 15:38:11 2009] [error] [client 127.0.0.1] File "/var/www/
wsgi-bin/dtm_app/dtm_test_app.wsgi", line 10, in ?
[Sun Nov 29 15:38:11 2009] [error] [client 127.0.0.1] import
webapp, simplejson
[Sun Nov 29 15:38:11 2009] [error] [client 127.0.0.1] ImportError: No
module named simplejson

Any solutions?

Thanks!

On Nov 29, 3:05 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> How are you configuring the location of the Python EGG cache. Are you using:
>
> 1. WSGIPythonEggs directive? Which means you MUST be using embedded mode.
>
> 2. Setting python-eggs option to WSGIDaemonProcess? Which means you
> MUST be using daemon mode and application must be properly delegated
> to that daemon mode process.
>
> 3. Setting PYTHON_EGG_CACHE in os.environ in WSGI script file?
>
> 4. Some other way?
>
> You need to provide more information about your configuration. Right
> now, you aren't using the correct way of setting Python egg cache for
> how you are running your application.
>
> Graham
>
> 2009/11/29 Hang-A <mhwa...@gmail.com>:

Graham Dumpleton

unread,
Nov 29, 2009, 5:51:20 PM11/29/09
to mod...@googlegroups.com
2009/11/30 Hang-A <mhw...@gmail.com>:
> I am using mod_wsgi in embedded mode.
> And #3 is my current configuration option.
> My application code starts as follows:
>
> import os, sys
> os.environ['PYTHON_EGG_CACHE'] = '/egg_cache'
> abspath = os.path.dirname(__file__)
> sys.path.append(abspath)
> os.chdir(abspath)

Provide output from:

ls -las /egg_cache

so can confirm ownership of directory and contents.

Ensure that there is no residual stuff in directory from previously
with different ownership.

> import webapp, simplejson
> ...
>
> I will continue to using the embedded mode.
> How different are your #1 and #2?

Only #1 is usable in embedded mode. It has same effect as setting in
WSGI script, although since done in Apache configuration will
automatically be applied to all WSGI applications running in embedded
mode and not just that singe one.

The #2 option is equivalent to #1 if using daemon mode.

Only other thing that can think of that will cause an issue on RedHat
is if SELinux extension enabled.

Graham

Hang-A

unread,
Nov 29, 2009, 6:15:30 PM11/29/09
to modwsgi


On Nov 29, 3:51 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> 2009/11/30 Hang-A <mhwa...@gmail.com>:
>
> > I am usingmod_wsgiin embedded mode.
> > And #3 is my current configuration option.
> > My application code starts as follows:
>
> > import os, sys
> > os.environ['PYTHON_EGG_CACHE'] = '/egg_cache'
> > abspath = os.path.dirname(__file__)
> > sys.path.append(abspath)
> > os.chdir(abspath)
>
> Provide output from:
>
>   ls -las /egg_cache
>
> so can confirm ownership of directory and contents.
>

The output is as follows:
total 16
8 drwxr-xr-x 2 apache root 4096 Nov 29 15:56 .
8 drwxr-xr-x 26 root root 4096 Nov 29 15:36 ..

> Ensure that there is no residual stuff in directory from previously
> with different ownership.
>
> > import webapp,simplejson
> > ...
>
> > I will continue to using the embedded mode.
> > How different are your #1 and #2?
>
> Only #1 is usable in embedded mode. It has same effect as setting in
> WSGI script, although since done in Apache configuration will
> automatically be applied to all WSGI applications running in embedded
> mode and not just that singe one.
>
> The #2 option is equivalent to #1 if using daemon mode.
>
> Only other thing that can think of that will cause an issue on RedHat
> is ifSELinuxextension enabled.

I've noticed that SELinux is enabled.
Since I am not familiar with this, I'm studying it.

Thanks for your comments.

Graham Dumpleton

unread,
Nov 29, 2009, 6:24:34 PM11/29/09
to mod...@googlegroups.com

Hang-A

unread,
Nov 29, 2009, 11:14:27 PM11/29/09
to modwsgi
It was because SELinux was enabled.
Thanks, Graham! You saved me!

On Nov 29, 4:24 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> See:
>
> http://www.crypt.gen.nz/selinux/disable_selinux.html
>
> Graham
>
> 2009/11/30 Hang-A <mhwa...@gmail.com>:

Clodoaldo Neto

unread,
Nov 30, 2009, 6:15:14 AM11/30/09
to mod...@googlegroups.com
2009/11/29 Hang-A <mhw...@gmail.com>:
> Thanks for your hint, Clodoaldo!
> Though I am not sure of what the repo is (I am new to linux and
> installed simplejson from source code),
> I will try to reinstall simplejson with easy_install.

Repo means the repositories defined in /etc/yum.repos.

Clodoaldo
Reply all
Reply to author
Forward
0 new messages