您的位置:首页 > 运维架构 > Nginx

nginx+uwsgi+django报错:[Errno 13] Permission denied: ‘/root/.python-eggs’

2013-06-08 14:38 387 查看
转自:/article/10091762.html

[python] view
plaincopy

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'

实际上也就是:安装的MySQL_python-1.2.3c1-py2.6-linux-x86_64.egg需要解压到/root/.python-eggs目录,而Apache访问的用户并没有该目录的write权限。

一个fix方法是在修改你的django.wsgi文件,添加PYTHON_EGG_CACHE的设置,先

mkdir /tmp/.python-eggs

uwsgi.py 加上:

[python] view
plaincopy

if sys.platform <> "win32":

os.environ['PYTHON_EGG_CACHE'] = '/tmp/.python-eggs'

另一个简单的fix的方法就是将MySQL解压成目录结构:

[python] view
plaincopy

$ cd /usr/lib/python2.6/site-packages/ (or wherever your site-packages are)

$ file MySQL_python-1.2.3c1-py2.6-linux-x86_64.egg

$ unzip -t MySQL_python-1.2.3c1-py2.6-linux-x86_64.egg

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

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

$ cd MySQL_python-1.2.3c1-py2.6-linux-x86_64.egg/

$ unzip ../foo.zip

$ rm ../foo.zip


关于django发布时发生的500错误

在完成所有配置,应用程序也已经初始化了(数据库),但是在访问的时候发生了500的错误,不得其解,权限什么的也重新分配了,但问题依旧,在查看日志的时候,发现了这样的错误:

mod_wsgi (pid=2939): Exception occurred processing WSGI script '/web/wsgi/mysite.wsgi'.

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] Traceback (most recent call last):

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 241, in __call__

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] response = self.get_response(request)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/core/handlers/base.py", line 73, in get_response

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] response = middleware_method(request)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/contrib/sessions/middleware.py", line 10, in process_request

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] engine = import_module(settings.SESSION_ENGINE)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] __import__(name)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/contrib/sessions/backends/db.py", line 2, in <module>

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] from django.contrib.sessions.models import Session

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/contrib/sessions/models.py", line 4, in <module>

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] from django.db import models

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/db/__init__.py", line 41, in <module>

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] backend = load_backend(settings.DATABASE_ENGINE)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/db/__init__.py", line 17, in load_backend

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] return import_module('.base', 'django.db.backends.%s' % backend_name)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] __import__(name)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/django/db/backends/mysql/base.py", line 10, in <module>

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] import MySQLdb as Database

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "build/bdist.linux-i686/egg/MySQLdb/__init__.py", line 19, in <module>

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "build/bdist.linux-i686/egg/_mysql.py", line 7, in <module>

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "build/bdist.linux-i686/egg/_mysql.py", line 4, in __bootstrap__

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg/pkg_resources.py", line 800, in resource_filename

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] self, resource_name

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg/pkg_resources.py", line 1228, in get_resource_filename

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] self._extract_resource(manager, self._eager_to_zip(name))

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg/pkg_resources.py", line 1250, in _extract_resource

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] self.egg_name, self._parts(zip_path)

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg/pkg_resources.py", line 880, in get_cache_path

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] self.extraction_error()

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] File "/usr/local/python25/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg/pkg_resources.py", line 846, in extraction_error

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] raise err

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] ExtractionError: Can't extract file(s) to egg cache

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172]

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] The following error occurred while trying to extract file(s) to the Python egg

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] cache:

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172]

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] [Errno 13] Permission denied: '/root/.python-eggs'

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172]

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] The Python egg cache directory is currently set to:

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172]

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] /root/.python-eggs

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172]

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] Perhaps your account does not have write access to this directory? You can

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] change the cache directory by setting the PYTHON_EGG_CACHE environment

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172] variable to point to an accessible directory.

[Sat Jan 23 13:49:40 2010] [error] [client 120.32.59.172]

这样的话意思是缓存没有权限写入,于是在mysite.wsgi里加了这么一句话,设置cache的路径,要保证该路径的文件夹权限是可写的。
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: