简体   繁体   English

在Mac Snow Leopard OS 10.6上安装MySQL-python时出错

[英]Error installing MySQL-python on MAC Snow Leopard, OS 10.6

I am trying to install the MySQL-python on MAC OS 10.6 (Snow leopard, 64 bit). 我正在尝试在MAC OS 10.6(雪豹,64位)上安装MySQL-python。 I followed the steps: 1. Installed MySQL for Mac OS X ver. 我按照以下步骤操作:1.为Mac OS X ver安装了MySQL。 10.6 (x86, 64-bit), DMG Archive. 10.6(x86,64位),DMG存档。 2. Downloaded MySQL-python-1.2.3c1.tar.gz and unzipped it 3. CD to MySQL-python-1.2.3c1 and built it as: ARCHFLAGS="-arch x86_64" python setup.py build (see output bnelow) 4. Installed it as: ARCHFLAGS="-arch x86_64" python setup.py install 5. But when I tried to import MySQLdb to python, I am getting error message 2.下载MySQL-python-1.2.3c1.tar.gz并将其解压缩。3.将CD下载到MySQL-python-1.2.3c1并构建为:ARCHFLAGS =“-arch x86_64” python setup.py build(请参见下面的输出) 4.将其安装为:ARCHFLAGS =“-arch x86_64” python setup.py install 5.但是,当我尝试将MySQLdb导入python时,出现错误消息

import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.3-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
  File "build/bdist.macosx-10.3-x86_64/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.3-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/krokodil/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
 /Users/krokodil/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg-tmp/_mysql.so: mach-o, but wrong architecture

This "macosx-10.3-x86_64" is bothering me - it seems that somehow the build/install thought that I am still on Mac OS 10.3. 这个“ macosx-10.3-x86_64”困扰着我-似乎以某种方式构建/安装认为我仍然在Mac OS 10.3上。 Please also see Build and Install capture below. 另请参阅下面的“构建和安装”捕获。 It also using /Developer/SDKs/MacOSX10.4u.sdk compiler, not /Developer/SDKs/MacOSX10.6.sdk 它还使用/Developer/SDKs/MacOSX10.4u.sdk编译器,而不是/Developer/SDKs/MacOSX10.6.sdk

I am using fresh install of Python 2.6.4. 我正在使用全新安装的Python 2.6.4。 I saw people having probles. 我看到人们有问题。 Anyone found a good solution? 有人找到一个好的解决方案吗?

Thank you Vlad 谢谢弗拉德

BUILD 建立

krokodil:MySQL-python-1.2.3c1 krokodil$  ARCHFLAGS="-arch x86_64" python setup.py build 
running build
running build_py
creating build
creating build/lib.macosx-10.3-x86_64-2.6
copying _mysql_exceptions.py -> build/lib.macosx-10.3-x86_64-2.6
creating build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
creating build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-x86_64-2.6
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.3-x86_64-2.6/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:805:1: warning: this is the location of the previous definition
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup -arch x86_64 build/temp.macosx-10.3-x86_64-2.6/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-x86_64-2.6/_mysql.so

INSTALL 安装

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

Installed /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg
Processing dependencies for MySQL-python==1.2.3c1
Finished processing dependencies for MySQL-python==1.2.3c1

The python 2.6.4 you are using is 32-bit only (definitely true if you downloaded the OS X installer from python.org). 您使用的python 2.6.4仅是32位的(如果从python.org下载了OS X安装程序,则绝对正确)。 You can't override the architecture for extension modules; 您不能覆盖扩展模块的体系结构。 they have to be compatible with the base python. 它们必须与基本python兼容。 The 10.3 shows up because the python you are using was built with a deployment target of 10.3 as it is designed to run on multiple versions of OS X. If you want to use a 64-bit version of MySQL, you'll need to use a 64-bit version of python, like the Apple-suppled python 2.6.1. 之所以显示10.3是因为您使用的python是为10.3部署目标而构建的,因为它旨在运行在多个OS X版本上。如果要使用64位版本的MySQL,则需要使用一个64位版本的python,例如Apple支持的python 2.6.1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM