[英]Problem using MySQLdb on OSX: symbol not found _mysql_affected_rows
This is related to a previous question . 这与先前的问题有关 。
However, the main posted solution there is not working for me. 但是,主要发布的解决方案对我不起作用。 I'm on Snow Leopard, using the 32-bit 5.1.49 MySQL dmg install.
我在Snow Leopard上,使用32位5.1.49 MySQL dmg安装。
I'm using the built in python
(apparently, as noted in the comments, my Python version is different), which appears to be 2.6.5 32-bit:
我正在使用内置的python
(显然,如注释中所述,我的Python版本是不同的),它似乎是2.6.5 32位:
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.maxint 2147483647
I've downloaded MySQL-python 1.2.3 from the usual location and changed site.cfg so that mysql_config points to the right place and the registry_key directive is commented out. 我已经从通常的位置下载了MySQL-python 1.2.3,并更改了site.cfg,以便mysql_config指向正确的位置,并且注解了register_key指令。 The packages seems to build and install just fine:
这些软件包似乎可以构建和安装:
caywork:MySQL-python-1.2.3 carl$ python setup.py clean running clean caywork:MySQL-python-1.2.3 carl$ python setup.py build running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.6/MySQLdb running build_ext caywork:MySQL-python-1.2.3 carl$ sudo python setup.py install running install running bdist_egg running egg_info writing MySQL_python.egg-info/PKG-INFO writing top-level names to MySQL_python.egg-info/top_level.txt writing dependency_links to MySQL_python.egg-info/dependency_links.txt reading manifest file 'MySQL_python.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'MANIFEST' warning: no files found matching 'ChangeLog' warning: no files found matching 'GPL' writing manifest file 'MySQL_python.egg-info/SOURCES.txt' installing library code to build/bdist.macosx-10.3-fat/egg running install_lib running build_py copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.6/MySQLdb running build_ext creating build/bdist.macosx-10.3-fat/egg copying build/lib.macosx-10.3-fat-2.6/_mysql.so -> build/bdist.macosx-10.3-fat/egg copying build/lib.macosx-10.3-fat-2.6/_mysql_exceptions.py -> build/bdist.macosx-10.3-fat/egg creating build/bdist.macosx-10.3-fat/egg/MySQLdb copying build/lib.macosx-10.3-fat-2.6/MySQLdb/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb copying build/lib.macosx-10.3-fat-2.6/MySQLdb/connections.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb creating build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/CR.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/ER.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants copying build/lib.macosx-10.3-fat-2.6/MySQLdb/converters.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb copying build/lib.macosx-10.3-fat-2.6/MySQLdb/cursors.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb copying build/lib.macosx-10.3-fat-2.6/MySQLdb/release.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb copying build/lib.macosx-10.3-fat-2.6/MySQLdb/times.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb byte-compiling build/bdist.macosx-10.3-fat/egg/_mysql_exceptions.py to _mysql_exceptions.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py to __init__.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/connections.py to connections.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/__init__.py to __init__.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/CR.py to CR.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/ER.py to ER.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/FLAG.py to FLAG.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/converters.py to converters.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/cursors.py to cursors.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/release.py to release.pyc byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/times.py to times.pyc creating stub loader for _mysql.so byte-compiling build/bdist.macosx-10.3-fat/egg/_mysql.py to _mysql.pyc creating build/bdist.macosx-10.3-fat/egg/EGG-INFO copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO writing build/bdist.macosx-10.3-fat/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents... creating 'dist/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg' and adding 'build/bdist.macosx-10.3-fat/egg' to it removing 'build/bdist.macosx-10.3-fat/egg' (and everything under it) Processing MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg Removing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg Copying MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg to /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages MySQL-python 1.2.3 is already the active version in easy-install.pth Installed /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg Processing dependencies for MySQL-python==1.2.3 Finished processing dependencies for MySQL-python==1.2.3
But when I try to use it, I get this: 但是当我尝试使用它时,我得到了:
caywork:MySQL-python-1.2.3 carl$ python -c "import MySQLdb" /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg/_mysql.pyc, but /Users/carl/Source/MySQL-python-1.2.3 is being added to sys.path Traceback (most recent call last): File "", line 1, in File "MySQLdb/__init__.py", line 19, in import _mysql File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/carl/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows Referenced from: /Users/carl/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so Expected in: dynamic lookup
All I can find on the web are older examples of this problem, along with numerous rants about how hard it is to get MySQL-python working on OSX. 我在网上可以找到的都是这个问题的较早的例子,以及关于在OSX上使MySQL-python工作变得多么困难的众多抱怨。 If anyone can help with this, I would greatly appreciate it!!
如果有人可以提供帮助,我将不胜感激!
The only (admittedly kludgy) solution that I ended up getting to work was to use MySQL-python-1.2.2 after applying this patch , cobbled together from advice found here ( http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/ ) and here ( http://flo.nigsch.com/?p=62 ). 我最终开始工作的唯一(公认的)解决方案是在应用此修补程序后使用MySQL-python-1.2.2,并从此处的建议中汇总了这些内容( http://www.mangoorange.com/2008/08/ 01 / installing-python-mysqldb-122-on-mac-os-x / )和此处( http://flo.nigsch.com/?p=62 )。 Sorry for the lack of links but I don't have enough rep points to post more than one link.
很抱歉缺少链接,但我没有足够的代表积分来发布多个链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.