Django - MySQLdb: Symbol not found: _mysql_affecte

2020-01-31 11:19发布

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?

7条回答
成全新的幸福
2楼-- · 2020-01-31 11:38

Try to run:

easy_install -U distribute
pip install --upgrade mysql-python

Note: If you have any errors of missing symbols while compiling, you need to have mysql development libs to compile it.

On Linux it's easy to install it:

sudo apt-get install mysql-devel

or:

sudo yum install mysql-devel

On Mac you probably need to download MySQL Connector and then you may have to pass in a --with-mysql-libs option to point to the directory when the C libraries are unpacked to. Or you can try to put the libraries in the default directory: /usr/lib64/mysql

查看更多
登录 后发表回答