python-eggs
Let me first state this for the record: I am not a server guy. The closest I've ever gotten to compiling my own versions of code is "sudo port install ..." So when I decided to teach myself Python (creating simply database interaction, record listings, etc) and kept getting "500 Internal Server Error" messages, I thought I was doomed. I opened up the Apache error log and saw this:
让我首先说明一下:我不是服务器人员。 我编译过的最接近我自己的代码版本的是“ sudo port install ...”,所以当我决定自学Python(创建简单的数据库交互,记录列表等)并不断收到“ 500 Internal Server Error ”消息,我以为我注定了。 我打开了Apache错误日志,并看到了以下内容:
[error] [client ::1] Traceback (most recent call last):
[error] [client ::1] File "/Users/davidwalsh83/Projects/server/something.py", line 6, in <module>
[error] [client ::1] import MySQLdb, cgi, cgitb, httplib, urllib2
[error] [client ::1] File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
[error] [client ::1] File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
[error] [client ::1] File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 4, in __bootstrap__
[error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 835, in resource_filename
[error] [client ::1] self, resource_name
[error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 1304, in get_resource_filename
[error] [client ::1] self._extract_resource(manager, self._eager_to_zip(name))
[error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 1326, in _extract_resource
[error] [client ::1] self.egg_name, self._parts(zip_path)
[error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 915, in get_cache_path
[error] [client ::1] self.extraction_error()
[error] [client ::1] File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 881, in extraction_error
[error] [client ::1] raise err
[error] [client ::1] pkg_resources.ExtractionError: Can't extract file(s) to egg cache
[error] [client ::1]
[error] [client ::1] The following error occurred while trying to extract file(s) to the Python egg
[error] [client ::1] cache:
[error] [client ::1]
[error] [client ::1] [Errno 20] Not a directory: '/Library/WebServer/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp'
[error] [client ::1]
[error] [client ::1] The Python egg cache directory is currently set to:
[error] [client ::1]
[error] [client ::1] /Library/WebServer/.python-eggs
[error] [client ::1]
[error] [client ::1] Perhaps your account does not have write access to this directory? You can
[error] [client ::1] change the cache directory by setting the PYTHON_EGG_CACHE environment
[error] [client ::1] variable to point to an accessible directory.
[error] [client ::1]
[error] [client ::1] Premature end of script headers: something.py
My first thought was "Wow, that's quite a long way of telling me to 'just quit.'" Not wanting to concede defeat, I did some quick Google searching to find that the following snippet of Python code would allow me program another day:
我的第一个念头是“哇,那是告诉我'退出'的很长的路。”不想让失败,我做了一些Google快速搜索,发现以下Python代码段可以让我改天编程:
import os
os.environ['PYTHON_EGG_CACHE'] = '/tmp'
I'd like to pretend I know what that means but I really don't know. In any event, if you start receiving those errors, this snippet could be your ticket to taking a bite out of Python.
我想假装我知道那意味着什么,但我真的不知道。 无论如何,如果您开始收到这些错误,则此片段可能是您咬一口Python的门票。
python-eggs