2011-04-01 136 views
1

可能重複:
Python import MySQLdb error - Mac 10.6錯誤加載MySQLdb的模塊

我有一個問題,當我使用與WSGI阿帕奇運行一個Django項目系統,mysqldb無法加載,並且系統報告如下錯誤:

... 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/util.py", line 1, in <module> 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  from django.db import models 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 78, in <module> 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  connection = connections[DEFAULT_DB_ALIAS] 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__ 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  backend = load_backend(db['ENGINE']) 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 33, in load_backend 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  return import_module('.base', backend_name) 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  __import__(name) 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/gis/db/backends/mysql/base.py", line 1, in <module> 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  from django.db.backends.mysql.base import * 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module> 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1]  raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] TemplateSyntaxError: Caught ImproperlyConfigured while rendering: Error loading MySQLdb module: dlopen(/Users/LechterLin/.python-eggs/MySQL_python-1.2.3-p 
    y2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] Referenced from: /Users/LechterLin/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so 
    [Fri Apr 01 11:00:11 2011] [error] [client ::1] Reason: image not found 

django項目中的wsgi文件和apache中的httpd.conf是正確的,因爲我在WindowsXP中使用相同的文件(或命令),項目可以成功運行。

此報告與錯誤類似,只安裝python和MySQL,沒有MySQL-python適配器。那麼這兩個錯誤有什麼關係?

我通過google搜索了這個錯誤,似乎這個問題只能在MACOSX10.6中找到。 我的系統問題,就像下面: 鋨:MACOSX10.6.7雪豹 MySQL的:5.5.10 蟒蛇:2.7 的MySQL-python的適配器:1.2.3 阿帕奇:2.2.17 的mod_wsgi:3.3 Django的:1.3

希望能得到您的幫助!非常感謝!

+0

http://stackoverflow.com/questions/4730787/python-import-mysqldb-error-mac-10-6的另一個副本 – DTing 2011-04-01 06:35:59

回答

1

去閱讀:

https://groups.google.com/d/topic/modwsgi/aNSeRUiF1OY/discussion

經過檢查那裏的基礎上,在那裏你安裝的東西在必要時調整。

然後在mod_wsgi郵件列表上跟隨那個討論,得到的結果可以進一步調試。 StackOverflow不適合作爲嘗試和調試問題的好地方,只有在有人知道確切答案時纔有用。不幸的是,最後一個遇到問題的人不能回答問題或指出他們如何解決問題,因此目前還沒有明確的簡短答案。

相關問題