python 导入 (MySQLdb) 和 apache python_egg_cache 的问题
我在 php 调用 python 脚本时遇到问题,或者它调用脚本时遇到问题,但在添加到我的用户 .bash_profile 后尝试导入 MySQLdb 时停止在途中的某个地方
,遵循本指南 如何修复开始的 Trac 安装给出与 PYTHON_EGG_CACHE?
export PYTHON_EGG_CACHE /var/www/html/path/cache
和 httpd.conf
AddHandler mod_python
SetEnv PYTHON_EGG_CACHE /var/www/html/path/cache
相关的错误我仍然收到此错误消息,网络服务器仍然尝试访问 /root/.python-eggs 我在新文件夹中找不到导出的 .python-eggs
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
尝试将文件提取到 Python Egg 时发生以下错误 缓存:
[Errno 13] Permission denied: '/root/.python-eggs'
Python Egg 缓存目录当前设置为:
/root/.python-eggs
也许您的帐户没有对此目录的写权限?你可以 通过设置 PYTHON_EGG_CACHE 环境更改缓存目录 变量指向可访问的目录。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 trac 的错误跟踪器 或 这个问题。您应该能够以某种方式修复 apache 的环境(最有可能以发行版/操作系统特定的方式),或者只是升级 trac。
更新:该问题并非 Trac/Genshii 特有的,每个在 apache 内运行并尝试安装 python Egg 的 python 应用程序都会发生这种情况。我使用 Trac 遇到了它并解决了编辑 Web 服务器环境的问题。 此 wiki 页面 明确指出 apache 的
SetEnv
指令不起作用,您应该使用PythonOption
。至于修改Web服务器的环境,我在FreeBSD服务器上做到了这一点(您只需在/usr/local/etc/apache22/envvars.d
中添加一个带有您需要的环境变量的脚本)并且我怀疑你可以在 Ubuntu 上编辑/etc/apache2/envvars
实现同样的效果。如果您使用的是另一个发行版,只需检查您的 apache 是如何打包的并采取相应的操作。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 usePythonOption
. 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.