I have trouble with php calling a python script, or its calling the script but stops somewhere on the way when trying to import MySQLdb
now after adding, to my user .bash_profile, following this guide How do you fix a Trac installation that begins giving errors relating to开发者_开发百科 PYTHON_EGG_CACHE?
export PYTHON_EGG_CACHE /var/www/html/path/cache
and to httpd.conf
AddHandler mod_python
SetEnv PYTHON_EGG_CACHE /var/www/html/path/cache
i still get this error message, the webserver still try to access /root/.python-eggs and i cant find my exported .python-eggs in my new folder
Array
(
[stdout] =>
[stderr] => Traceback (most recent call last):
File "/var/www/html/grndb/upscgenesearch/python/pythontest.py", line 4, in ?
import MySQLdb
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in ?
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in ?
File "build/bdist.linux-x86_64/egg/_mysql.py", line 4, in __bootstrap__
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 799, in resource_filename
return get_provider(package_or_requirement).get_resource_filename(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1229, in get_resource_filename
return self._extract_resource(manager, zip_path)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1249, in _extract_resource
real_path = manager.get_cache_path(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 880, in get_cache_path
self.extraction_error()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 846, in extraction_error
raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg cache:
[Errno 13] Permission denied: '/root/.python-eggs'
The Python egg cache directory is currently set to:
/root/.python-eggs
Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory.
Have a look at trac's bug tracker or this question. You should be able to fix apache's environment in some way (most likely in a distribution/os specific way), or just upgrade trac.
Update: The problem is not specific to Trac/Genshii, it happens with each python application running inside apache and trying to install a python egg. I came across it using Trac and solved editing the web server's environment. This wiki page explicitly says that apache's SetEnv
directive won't work, you should use PythonOption
. As for modifying the web server's environment I did that on a FreeBSD server (where you just add a script with the environment vars you nedd inside /usr/local/etc/apache22/envvars.d
) and I suspect you could achieve the same on Ubuntu editing /etc/apache2/envvars
. If you are on another distro just check how your apache is packaged and act accordingly.
精彩评论