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
在完成所有配置,应用程序也已经初始化了(数据库),但是在访问的时候发生了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的路径,要保证该路径的文件夹权限是可写的。
[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'
相关文章推荐
- nginx+uwsgi+django报错:[Errno 13] Permission denied: ‘/root/.python-eggs’
- 装完 mysql-python 报错 [Errno 13] Permission denied: '/root/.python-eggs'
- ExtractionError: Can’t extract file(s) to egg cache, [Errno 13] Permission denied: ‘/root/.python-eggs’
- Nginx+uWsgi+Django+Python+MongoDB+mySQL服务器搭建
- centos 下 安装python,django,uwsgi,nginx
- python+uwsgi+django+nginx配置与…
- Python-django-uwsgi-nginx环境
- uwsgi+nginx+django+python
- ubuntu 14.04部署python项目(Nginx+uwsgi+django)
- Ubuntu+Django+Nginx+uWSGI+Mysql搭建Python Web服务器
- python Django Nginx+ uWSGI 安装配置
- Nginx + uWSGI + Python + Django部署实例
- Ubuntu 14.04---Nginx+uWsgi+Django+Python+MongoDB+m
- python django+uwsgi+nginx
- python+django+nginx+uwsgi环境解决timeout 504
- Python-Django Nginx+uwsgi 安装配置
- mysql + Python3.5.2 + Django + Uwsgi + Nginx实现生产环境
- python django+uwsgi+nginx 搭建步骤(血一般的教训)
- Nginx+uWSGI+DJango+Python+ Mysql 搭建可靠的python web服务
- linux下搭建nginx,uwsgi和python的flask和django网站