我正在尝试从php网页执行python脚本。 python脚本使用netsnmp模块,它在httpd error_log中记录了以下错误:
Traceback (most recent call last): File "/var/www/html/backendscripts/updateMachine.py", line 5, in import netsnmp . . . The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '**/var/www/.python-eggs/netsnmp_python-1.0a1-py2.5-linux-i686.egg-tmp'** The Python egg cache directory is currently set to: /var/www/.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.
python egg缓存位于/root/.python-eggs/
目录中。
我还在/var/www/
目录中创建了一个指向egg cache目录的软链接,该目录具有对所有用户的完全权限。
/var/www/.python-eggs - > /root/.python-eggs
[root@localhost .python-eggs]# pwd /var/www/.python-eggs [root@localhost .python-eggs]# ls -lR . .: total 4 drwxrwxrwx 3 root root 4096 2011-10-07 02:17 netsnmp_python-1.0a1-py2.5-linux-i686.egg-tmp ./netsnmp_python-1.0a1-py2.5-linux-i686.egg-tmp: total 4 drwxrwxrwx 2 root root 4096 2010-06-09 22:21 netsnmp ./netsnmp_python-1.0a1-py2.5-linux-i686.egg-tmp/netsnmp: total 84 -rwxrwxrwx 1 root root 81349 2010-06-09 22:20 client_intf.so
我甚至在python脚本中将PYTHON_EGG_CACHE
环境变量设置为:
import os
os.environ['PYTHON_EGG_CACHE'] = '/var/www/.python-eggs/'**
但脚本仍无法执行。