开发者

MySQLdb problems in django

I installed mysql-python on 64bit snow leopard,and it's good under python IDE,but failed import in django. Anyone had meet similar question?

File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 14, in <modul开发者_如何学Ce>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: 
Error loading MySQLdb module: dlopen(/Users/szanlin/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 
2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/szanlin/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Reason: image not found


I had the same problem and I was able to find the answer here:

http://www.curlybrace.com/words/2011/01/25/mac-os-mysql-python-1-2-3-importerror-library-not-loaded-libmysqlclient-16-dylib/

Basically you need to add this line:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

to your /etc/bashrc file.

Another page that was helpful can be found here:

http://programmingzen.com/2007/12/22/how-to-install-django-with-mysql-on-mac-os-x/


Just the clarify the above answer. Great answer and PowerAnimal is correct. If I could vote him up I would.

Please add the line:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

to:

user/.bash_profile

This is a hidden file. You can view this file by using the following command in terminal.

defaults write com.apple.Finder AppleShowAllFiles YES

then:

killall Finder

When finished:

defaults write com.apple.Finder AppleShowAllFiles NO

then:

killall Finder

To check that Python is communicating with MySQL:

import MySQLdb

MySQLdb.apilevel

To check that Django is working:

import django

print django.VERSION

If no errors, you should be able to continue with your Django setup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜