2010-08-06 95 views
1

這與a previous question有關。在OSX上使用MySQLdb的問題:未找到符號_mysql_affected_rows

但是,主要的解決方案並不適合我。我在Snow Leopard上使用32位5.1.49 MySQL dmg安裝。 我使用的是內置的蟒蛇 (顯然,如在評論中指出,我的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 

我已經下載MySQL- python 1.2.3從the usual location並更改site.cfg,以便mysql_config指向正確的位置並且registry_key指令被註釋掉。包似乎構建和安裝就好了:

 

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 

但是當我嘗試使用它,我得到這個:

 

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 

我能在網上找到此問題的較舊的例子,以及許多關於如何讓MySQL-python在OSX上工作的爭論。如果任何人都可以提供幫助,我將不勝感激!

+0

請注意,您在10.6上未使用Apple提供的Python 2.6。這是'/ usr/bin/python'目前是Python 2.6.1。那是64位/ 32位通用版本。您最有可能使用python.org安裝程序中的32位Python 2.6(安裝在/Library/Frameworks/Python.framework ...)以及/usr/local/bin/python2.6中的鏈接。 – 2010-08-06 19:06:31

+0

謝謝Ned!如果我一直使用蘋果提供的Python,你認爲我遇到的這個問題會有所不同嗎? – cayblood 2010-08-07 08:02:20

+0

+1以允許您添加多個鏈接。與使用python 2.7.1 32bit的MySQL有類似的問題 – 2011-05-17 16:09:00

回答

相關問題