2012-11-18 1 views
12

여기 내 문제가 있습니다 : 나는 Python 작동 MySQLdb를 가져올 수 없습니다. 이것에 관한 다른 게시물 대부분은 MySQL/Python의 다른 아키텍처를 가지고 있다고 언급했습니다. 나는 체크했다. 그리고 그들은 64 비트 다. 저는 파이썬 2.7.2 (표준 OS X)와 최신 MySQL, OS X 10.8.2를 가지고 있습니다.OSX 10.8.2 및 둘 모두에 Python 2.7 용 MySQLdb는 64 비트입니다

내 원래의 오류 로그 : MySQL의 DB를 가져 오려는

날이 오류를 제공합니다 : 나는이 MySQL을 - 파이썬 1.2을 설치하는 동안

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/__init__.py", line 19, in <module> 
    import _mysql 
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib 
    Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so 
    Reason: image not found 

이 콘솔 출력뿐만 아니라 도움이 될 수 있습니다. 4b4

xxx-MBP:MySQL-python-1.2.4b4 me$ sudo python setup.py clean 
running clean 
removing 'build/temp.macosx-10.8-intel-2.7' (and everything under it) 
xxx-MBP:MySQL-python-1.2.4b4 me$ 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 
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.8-intel/egg 
running install_lib 
running build_py 
copying MySQLdb/release.py -> build/lib.macosx-10.8-intel-2.7/MySQLdb 
running build_ext 
creating build/bdist.macosx-10.8-intel/egg 
copying build/lib.macosx-10.8-intel-2.7/_mysql.so -> build/bdist.macosx-10.8-intel/egg 
copying build/lib.macosx-10.8-intel-2.7/_mysql_exceptions.py -> build/bdist.macosx-10.8-intel/egg 
creating build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/__init__.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/connections.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
creating build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb/constants 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/release.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
copying build/lib.macosx-10.8-intel-2.7/MySQLdb/times.py -> build/bdist.macosx-10.8-intel/egg/MySQLdb 
byte-compiling build/bdist.macosx-10.8-intel/egg/_mysql_exceptions.py to _mysql_exceptions.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/__init__.py to __init__.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/connections.py to connections.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/__init__.py to __init__.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/CR.py to CR.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/ER.py to ER.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/FLAG.py to FLAG.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/converters.py to converters.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/cursors.py to cursors.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/release.py to release.pyc 
byte-compiling build/bdist.macosx-10.8-intel/egg/MySQLdb/times.py to times.pyc 
creating stub loader for _mysql.so 
byte-compiling build/bdist.macosx-10.8-intel/egg/_mysql.py to _mysql.pyc 
creating build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.8-intel/egg/EGG-INFO 
writing build/bdist.macosx-10.8-intel/egg/EGG-INFO/native_libs.txt 
zip_safe flag not set; analyzing archive contents... 
creating 'dist/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg' and adding 'build/bdist.macosx-10.8-intel/egg' to it 
removing 'build/bdist.macosx-10.8-intel/egg' (and everything under it) 
Processing MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 
removing '/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg' (and everything under it) 
creating /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 
Extracting MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg to /Library/Python/2.7/site-packages 
MySQL-python 1.2.4b4 is already the active version in easy-install.pth 

Installed /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 
Processing dependencies for MySQL-python==1.2.4b4 
Finished processing dependencies for MySQL-python==1.2.4b4 
+0

흥미로운 점은 설치를 청소 한 후 다음과 같습니다 (http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os). /) 지시 사항 (macports 부분이 나를 위해 작동하지 않았다), 특히 빌드 프로세스 중에 64 비트 플래그를 사용하여 다시 작성한 다음 다시 설치합니다. 지금은 무서운 것. MySQLdb 가져 오기는 터미널에서 작동하지만 코드 편집기에서는 작동하지 않습니다. – Tizzee

+0

참고로,/library/python에는 2.3, 2.4, 2.5, 2.6 및 2.7 용 폴더가 있지만 2.7 라이브러리에는 폴더가 있습니다. WITHIN 2.7 (/library/python/2.7/) 여러 달걀 파일, MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg 및 MySQL_python-1.2.4b4-py2.7-macosx -10.8-x86_64.egg이고 그 둘 모두 안에 같은 파일이 있습니다 ... 하나를 삭제해야합니까? 어느 것을 지켜야합니까? 나는 너무 극단적으로 좌절했다. – Tizzee

+0

참고 사항 : 내가 제어 할 경우 - | 터미널에있는 파이썬에서는 종료되지만, 파이썬이 예기치 않게 종료되었다는 OSX 창이 나타납니다. – Tizzee

답변

13

나는 생각한다! 여기 내가 한 일이있다.

OK이 작업은 매우 실망 스럽습니다.

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib 

그러나 다른 물건을 많이 그 전에 있었다 : 마지막으로이 작품은 터미널에서이 일을하고 만든 어떤

. 나는 두 개의 소스에서 방향을 혼합 : 나는 파이썬을 청소하고 빌드 파일을 변경하려면 먼저 사용

How to install MySQLdb (Python data access library to MySQL) on Mac OS X?http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/

... 나는 ...

설치하고 구축하는 64 개 비트 플래그를 추가하는 두 번째 사용

은 그 때 나는

은 가장자리에 저를 설정 (작동하게 마지막 일이었다.) Error importing MySQLdb in Python 2.7.2 on Mac OSx 10.8.1에 답변을 사용했다.

나는 너무 많은 일을했기 때문에 정확히 무엇이 달라 졌는지 확실하지 않습니다. 나는 2.7 python 폴더에서 많은 것들을 삭제했다 ... 그리고 다른 것들. 그러나 내가 확신 할 수있는 유일한 사실은이 두 출처의 지시를 섞으면 차이가 있다는 것입니다. 모든 도움을 주셔서 감사합니다, 얘들 아. .lol이 사람이 두통을 저장 바랍니다.

0

필자가 직면 한 4 가지 구성 장애를 나열했습니다. 필자는이를 나열했습니다.

수출 CFLAGS = -Qunused-인수 수출 CPPFLAGS = -Qunused-인수 엑스 코드 환경 설정/다운로드에서 명령 행 도구를 설치 sudo를 에선 -s /usr/local/mysql/lib/libmysqlclient.18.dylib는/usr /lib/libmysqlclient.18.dylib