修改 ModPython 下 PYTHON_EGG_CACHE 报错

环境:Linux Apache Python(mod_python)

换了一台新机器,没有配置Mod_Python了,在一些应用里import MySQLdb出现了下面错误:

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.

解决办法有两种:

1.设置PYTHON_EGG_CACHE环境变量

$ SetEnv PYTHON_EGG_CACHE /tmp/aaa/

目录权限注意要是apache用户,或者简单点就777

2.把egg格式转成目录

$ cd /python-path/site-packages/

$ mv MySQL_python-1.2.3c1-py2.5-linux-x86_64.egg foo.zip

$ mkdir MySQL_python-1.2.3c1-py2.5-linux-x86_64.egg

$ cd MySQL_python-1.2.3c1-py2.5-linux-x86_64.egg

$ unzip ../foo.zip

$ rm ../foo.zip

*********************************************************************************

换了一台新机器,没有配置Mod_Python了,在一些应用里import MySQLdb出现了下面错误:

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.

解决办法有两种:

1.设置PYTHON_EGG_CACHE环境变量

$ SetEnv PYTHON_EGG_CACHE /tmp/aaa/
##(setenv是在cshell中用的,在bshell中用的是   export

不同的SHELL设置变量的方法很不一致:
csh : set、setenv
bash : set、export
ksh : set、export或直接赋值
vim /etc/profile
export PYTHON_EGG_CACHE=/tmp/.python-eggs
source /etc/profile
export PYTHON_EGG_CACHE=/tmp/.python-eggs
env |grep egg
chmod -R 777 /tmp/.python-eggs
or # vi /root/.bashrc
export PYTHON_EGG_CACHE=/tmp/.python-eggs
)

目录权限注意要是apache用户,或者简单点就777

2.把egg格式转成目录

$ cd /python-path/site-packages/
$ mv MySQL_python-1.2.3c1-py2.5-linux-x86_64.egg foo.zip
$ mkdir MySQL_python-1.2.3c1-py2.5-linux-x86_64.egg
$ cd MySQL_python-1.2.3c1-py2.5-linux-x86_64.egg
$ unzip ../foo.zip
$ rm ../foo.zip

你可能感兴趣的:(apache,mysql,python,cache,File,Access)