Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

python - Django - MySQLdb: Symbol not found: _mysql_affected_rows

A colleague got this error message when trying to use MySQLdb from Django:

[...]
ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: 
Error loading MySQLdb module: dlopen(/Users/roy/.python-eggs/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): 
Symbol not found: _mysql_affected_rows 
Referenced from: /Users/roy/.python-eggs/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so Expected in: dynamic lookup

He's using OS X 10.5, Python 2.5 (arriving with OS X), MySQL 5.1 & MySQLdb 1.2.3c1.

Any idea how to attack this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It might be best if you install mysql and it's Python bindings from scratch, I use the following steps whenever I need MySQLdb on OS X 10.4 or 10.5:

  1. Install MySQL for your system, the dmg installer should be sufficient

  2. The default location of MySQL will be somewhere around: /usr/local/mysql-5.0.45-osx10.4-i686. From /usr/local/mysql/lib, create a soft link:

    ln -s ../../mysql-5.0.45-osx10.4-i686/lib mysql

  3. Download the MySQLdb source and unpack it

  4. Edit the file site.cfg under your unpacked MySQLdb directory, comment out the registry_key and set mysql_config to:

    mysql_config = /usr/local/mysql-5.0.45-osx10.4-i686/bin/mysql_config

  5. Carry on with the regular Python packages build from within MySQLdb directory:

    sudo python setup.py install

  6. If everything is fine above, test MySQLdb in a new terminal:

    python -c "import MySQLdb"

The above should return nothing if successful. The above example shows OS 10.4 and MySQL 5.0, substitute them with the your proper tools version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...