MySQLdb在macosx10.5和python2.7下安装

MySQLdb在macosx10.5和python2.7下安装,mysql,mysql-python,python-2.7,Mysql,Mysql Python,Python 2.7,我正试图让MySQL Python 1.2.3在MacBook Pro for Python 2.7(64位)上的Leopard下运行。我尝试过从源代码处构建和安装以及轻松安装,但运气不佳。当从源代码安装时,我在setup_posix.py中修改了mysql_config.path,这在另一个相关的回答中得到了建议 mysql\u config.path=“/usr/local/mysql-5.1.41-osx10.5-x86/bin/mysql\u config” 构建和安装似乎进展顺利。然而

我正试图让MySQL Python 1.2.3在MacBook Pro for Python 2.7(64位)上的Leopard下运行。我尝试过从源代码处构建和安装以及轻松安装,但运气不佳。当从源代码安装时,我在setup_posix.py中修改了mysql_config.path,这在另一个相关的回答中得到了建议

mysql\u config.path=“/usr/local/mysql-5.1.41-osx10.5-x86/bin/mysql\u config”

构建和安装似乎进展顺利。然而,在Python中键入“import MySQLdb”之后,我得到了以下结果

>>> import MySQLdb
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg/_mysql.pyc, but /Users/diehl4/Downloads/MySQL-python-1.2.3 is being added to sys.path
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/__init__.py", line 19, in <module>
    import _mysql
  File "build/bdist.macosx-10.5-fat3/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.5-fat3/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/diehl4/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
        /Users/diehl4/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg-tmp/_mysql.so: mach-o, but wrong architecture
以及来自安装的信息:

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.5-fat3/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.5-fat3-2.7/MySQLdb
running build_ext
creating build/bdist.macosx-10.5-fat3
creating build/bdist.macosx-10.5-fat3/egg
copying build/lib.macosx-10.5-fat3-2.7/_mysql.so -> build/bdist.macosx-10.5-fat3/egg
copying build/lib.macosx-10.5-fat3-2.7/_mysql_exceptions.py -> build/bdist.macosx-10.5-fat3/egg
creating build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/__init__.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/connections.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
creating build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/release.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/times.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
byte-compiling build/bdist.macosx-10.5-fat3/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.5-fat3/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
writing build/bdist.macosx-10.5-fat3/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg' and adding 'build/bdist.macosx-10.5-fat3/egg' to it
removing 'build/bdist.macosx-10.5-fat3/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg
Copying MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Adding MySQL-python 1.2.3 to easy-install.pth file

答案是这样的。我首先安装了64位的Python和32位的MySQL。我刚刚发现了后者。安装32位版本的Python2.7消除了上述问题

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.5-fat3/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.5-fat3-2.7/MySQLdb
running build_ext
creating build/bdist.macosx-10.5-fat3
creating build/bdist.macosx-10.5-fat3/egg
copying build/lib.macosx-10.5-fat3-2.7/_mysql.so -> build/bdist.macosx-10.5-fat3/egg
copying build/lib.macosx-10.5-fat3-2.7/_mysql_exceptions.py -> build/bdist.macosx-10.5-fat3/egg
creating build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/__init__.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/connections.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
creating build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/release.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
copying build/lib.macosx-10.5-fat3-2.7/MySQLdb/times.py -> build/bdist.macosx-10.5-fat3/egg/MySQLdb
byte-compiling build/bdist.macosx-10.5-fat3/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.5-fat3/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.5-fat3/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.5-fat3/egg/EGG-INFO
writing build/bdist.macosx-10.5-fat3/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg' and adding 'build/bdist.macosx-10.5-fat3/egg' to it
removing 'build/bdist.macosx-10.5-fat3/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg
Copying MySQL_python-1.2.3-py2.7-macosx-10.5-fat3.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Adding MySQL-python 1.2.3 to easy-install.pth file