MySQLdb Confusion

Sam stopchuckingstuff at me.com
Sat Jan 16 13:53:15 EST 2010


To the powers that be,

I am running Apache 2 on Mac OSX 10.6.2.

I have, after many hours, managed to install MySQLdb, however I'm not  
sure if I installed it correctly as I had to fudge it a little.

I can import and use the module fine in IDLE or in python from  
Terminal (which would suggest it installed correctly), however when I  
try and import the module in a cgi script, I get the following error  
out of cgitb:

<type 'exceptions.ImportError'>: No module named MySQLdb
       args = ('No module named MySQLdb',)
       message = 'No module named MySQLdb'

MySQLdb installed inside a .egg file in /Library/Frameworks/ 
Python.framework/Versions/2.6/lib/python2.6/site-packages, so I  
appended this to sys.path, and got a new error:
"
Traceback (most recent call last):
   File "/Users/Sam/Sites/Spoonful/cgi-bin/view.py", line 19, in  
<;module>;
     import MySQLdb
   File "build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py", line  
19, in <;module>;
   File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in  
<;module>;
   File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 4, in  
__bootstrap__
   File "/System/Library/Frameworks/Python.framework/Versions/2.6/ 
Extras/lib/python/pkg_resources.py", line 835, in resource_filename
     self, resource_name
   File "/System/Library/Frameworks/Python.framework/Versions/2.6/ 
Extras/lib/python/pkg_resources.py", line 1304, in get_resource_filename
     self._extract_resource(manager, self._eager_to_zip(name))
   File "/System/Library/Frameworks/Python.framework/Versions/2.6/ 
Extras/lib/python/pkg_resources.py", line 1326, in _extract_resource
     self.egg_name, self._parts(zip_path)
   File "/System/Library/Frameworks/Python.framework/Versions/2.6/ 
Extras/lib/python/pkg_resources.py", line 915, in get_cache_path
     self.extraction_error()
   File "/System/Library/Frameworks/Python.framework/Versions/2.6/ 
Extras/lib/python/pkg_resources.py", line 881, in extraction_error
     raise err
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: '/Library/WebServer/.python-eggs'

The Python egg cache directory is currently set to:

   /Library/WebServer/.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.
"

I have no idea what to from there?!

Apologies for the long question, but I've read many in which people  
complained about not enough detail, so...
Thanks very much, and I hope someone can help!

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100116/1e88be71/attachment.html>


More information about the Python-list mailing list