2010-11-27 3 views
2

ich die tar.gz-Datei von http://sourceforge.net/projects/mysql-python/files/Probleme MYSQL-Python-1.2.3 für Python 2.7 auf Schnee Installation Leopard

unzip heruntergeladen haben, lief dann setup.py Python installieren, aber es sagte, es Setuptools Modul benötigt, so ich heruntergeladen Setuptools von http://pypi.python.org/pypi/setuptools#files Die Datei war Setuptools-0.6c11-py2.7.egg (md5), dann lief ich

sh setuptools-0.6c9-py2.4.egg 

dann zurück zu mysql-python-1.2.3-Ordner, lief ich

sudo setup.py install 

Nur für das Protokoll, hier ist das Installationsprotokoll:

MacBook-Pros-MacBook-Pro:MySQL-python-1.2.3 2 macbookpro$ 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 
creating build 
creating build/lib.macosx-10.3-fat-2.7 
copying _mysql_exceptions.py -> build/lib.macosx-10.3-fat-2.7 
creating build/lib.macosx-10.3-fat-2.7/MySQLdb 
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb 
copying MySQLdb/converters.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb 
copying MySQLdb/connections.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb 
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb 
copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb 
copying MySQLdb/times.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb 
creating build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants 
running build_ext 
building '_mysql' extension 
creating build/temp.macosx-10.3-fat-2.7 
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-fat-2.7/_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:1069:1: warning: "HAVE_WCSCOLL" redefined 
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8, 
       from pymemcompat.h:10, 
       from _mysql.c:29: 
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:881:1: warning: this is the location of the previous definition 
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-fat-2.7/_mysql.so -arch x86_64 
creating build/bdist.macosx-10.3-fat 
creating build/bdist.macosx-10.3-fat/egg 
copying build/lib.macosx-10.3-fat-2.7/_mysql.so -> build/bdist.macosx-10.3-fat/egg 
copying build/lib.macosx-10.3-fat-2.7/_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.7/MySQLdb/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb 
copying build/lib.macosx-10.3-fat-2.7/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.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb 
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/release.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb 
copying build/lib.macosx-10.3-fat-2.7/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 
creating 'dist/MySQL_python-1.2.3-py2.7-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.7-macosx-10.3-fat.egg 
Copying MySQL_python-1.2.3-py2.7-macosx-10.3-fat.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 

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg 
Processing dependencies for MySQL-python==1.2.3 
Finished processing dependencies for MySQL-python==1.2.3 

Da ist in meinem Django Projektordner Python manage.py runserver

aber es scheiterte ich lief, dies ergab:

Validating models... 
Unhandled exception in thread started by <function inner_run at 0x106df70> 
Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run 
    self.validate(display_num_errors=True) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate 
    num_errors = get_validation_errors(s, app) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/validation.py", line 22, in get_validation_errors 
    from django.db import models, connection 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 77, in <module> 
    connection = connections[DEFAULT_DB_ALIAS] 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 91, in __getitem__ 
    backend = load_backend(db['ENGINE']) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 32, in load_backend 
    return import_module('.base', backend_name) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module 
    __import__(name) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module> 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) 
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so, 2): no suitable image found. Did find: 
    /Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so: mach-o, but wrong architecture 

Hat jemand schon mal ein ähnliches Problem gehabt? Kann mir bitte jemand helfen? Danke

aktualisieren

file /Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so 

zurückgegeben:

/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so: Mach-O 64-bit bundle x86_64 

und

file `which python` 

zurückgegeben:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python: Mach-O universal binary with 2 architectures 
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (for architecture ppc): Mach-O executable ppc 
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (for architecture i386): Mach-O executable i386 

Update 1

Basierend auf den oben genannten Informationen, dachte ich, der Fehler durch Python in i386 installiert verursacht wurde, während MySQLdb in x86_64 (was immer das bedeutet ...) Also habe ich versucht, MySQLdb zu bauen mit Bogen i386 mit Technik in diesem Tutorial gezeigt: http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/, aber es hat nicht funktioniert, dann habe ich versucht, es mit x86_64 zu bauen, funktioniert auch nicht.

Hier ist meine Terminal Geschichte:

build mit i386:

ARCHFLAGS='-arch i386' python setup.py build 

zurückgegeben:

running build 
running build_py 
creating build/lib.macosx-10.3-i386-2.7 
copying _mysql_exceptions.py -> build/lib.macosx-10.3-i386-2.7 
creating build/lib.macosx-10.3-i386-2.7/MySQLdb 
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb 
copying MySQLdb/converters.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb 
copying MySQLdb/connections.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb 
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb 
copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb 
copying MySQLdb/times.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb 
creating build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants 
running build_ext 
building '_mysql' extension 
creating build/temp.macosx-10.3-i386-2.7 
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-i386-2.7/_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:1069:1: warning: "HAVE_WCSCOLL" redefined 
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8, 
       from pymemcompat.h:10, 
       from _mysql.c:29: 
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:881:1: warning: this is the location of the previous definition 
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-i386-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-i386-2.7/_mysql.so -arch x86_64 

dann das Setup ausgeführt:

ARCHFLAGS='-arch i386' python setup.py install 

Ergebnis:

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

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg 
Processing dependencies for MySQL-python==1.2.3 
Finished processing dependencies for MySQL-python==1.2.3 

Dann lief ich Python zu überprüfen, ob MySQLdb korrekt installiert:

MacBook-Pros-MacBook-Pro:MySQL-python-1.2.3 2 macbookpro$ python 
Python 2.7 (r27:82508, Jul 3 2010, 20:17:05) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import MySQLdb 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.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.3-i386.egg/_mysql.pyc, but /Users/macbookpro/Downloads/MySQL-python-1.2.3 2 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.3-i386/egg/_mysql.py", line 7, in <module> 
    File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in __bootstrap__ 
ImportError: dlopen(/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg-tmp/_mysql.so, 2): no suitable image found. Did find: 
    /Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg-tmp/_mysql.so: mach-o, but wrong architecture 

Dann, da es nicht funktioniert, habe ich versucht verzweifelt es mit -arch x86_64 zu bauen, aber nicht funktioniert, entweder:

ARCHFLAGS='-arch x86_64' python setup.py build 

running build 
running build_py 
creating build/lib.macosx-10.3-x86_64-2.7 
copying _mysql_exceptions.py -> build/lib.macosx-10.3-x86_64-2.7 
creating build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
copying MySQLdb/converters.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
copying MySQLdb/connections.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
copying MySQLdb/release.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
copying MySQLdb/times.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb 
creating build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants 
running build_ext 
building '_mysql' extension 
creating build/temp.macosx-10.3-x86_64-2.7 
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-x86_64-2.7/_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:1069:1: warning: "HAVE_WCSCOLL" redefined 
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8, 
       from pymemcompat.h:10, 
       from _mysql.c:29: 
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:881:1: warning: this is the location of the previous definition 
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-x86_64-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-x86_64-2.7/_mysql.so -arch x86_64 

dann Installation

ARCHFLAGS='-arch x86_64' python setup.py install 

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

Dann wieder habe ich versucht, in Python zu überprüfen

MacBook-Pros-MacBook-Pro:MySQL-python-1.2.3 2 macbookpro$ python 

die wiederum scheiterte

>>> import MySQLdb 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.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.3-x86_64.egg/_mysql.pyc, but /Users/macbookpro/Downloads/MySQL-python-1.2.3 2 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.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/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg-tmp/_mysql.so, 2): no suitable image found. Did find: 
    /Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg-tmp/_mysql.so: mach-o, but wrong architecture 

Gibt es irgendwo Ich habe vielleicht falsch gemacht?

Update 2

Ausführen dieses Code in Python (falls es kann Ihnen helfen, in irgendeiner Weise zu untersuchen)

>>> import math 
>>> import sys 
>>> math.log(sys.maxint, 2) 
30.999999999328196 

Danke

+0

Bitte zeigen Sie uns die Ausgabe von: 'file/Benutzer/macbookpro/.python-Eier/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so' und' file \ ' welches Python \ – cababunga

+0

Ich habe es aufgenommen, also, sagt es irgendetwas? – jaycode

Antwort

2

Die Ursache liegt wahrscheinlich darin, dass Sie nur eine 64-Bit-Version der MySQL-Clientbibliotheken installiert haben. Beachten Sie, dass der Buildprozess MySQLdb (in setup_posix.py) den Befehl mysql_build abfragt, um die verschiedenen Flags zu finden, die zum Erstellen der MySQL-Clientbibliotheken verwendet wurden, und um das Erstellen des Erweiterungsmoduls MySQLdb zu erweitern. Ihre Python-Instanz und Ihre MySQL-Client-Bibliotheken müssen mindestens eine gemeinsame Architektur haben.Installieren Sie entweder eine Version des MySQL-Clients mit 32-Bit-Intel (-arch i386) oder installieren Sie eine 64-Bit-Version von Python 2.7. Aus Gründen wie diesem empfehle ich die Installation einer vollständigen Django-Lösung (oder zumindest einer Python- und MySQL-Lösung) unter Verwendung von MacPorts, um solche Inkompatibilitäten zu vermeiden.

+0

Installierte 64-Bit-Version von Python 2.7 und es hat funktioniert, danke! – jaycode

0

Sie wahrscheinlich eine 32-Bit-mysql verwenden mit ein 64-Bit-Python (das in Snow Leopard Standard ist) oder umgekehrt.

Wenn dies nicht der Fall ist, dann schauen Sie auf die DMG MySQL kam herein, um die richtige MySQL-Python zu finden. Weitere Informationen finden Sie unter here.

aktualisieren
ich etwas verpasst ... ist Ihre Python-Installation 32 oder 64 Bit? Wenn Sie unsicher sind, fragen Sie bei diesem Code:

import math 
import sys 
math.log(sys.maxint, 2) 

Ich fürchte, Sie irgendwie die „matched“ Kombination der drei Programme verpasst haben.

+0

Die gcc-Anweisungen übergeben auch "-arch x86_64" (64-Bit) anstelle von "-arch i386" (32-Bit). –

+0

Versucht beide Bogen x86_64 und i386, aber hat nicht funktioniert (siehe mein Update oben), irgendwelche Gedanken? – jaycode

Verwandte Themen