OSX 10.8.2和BOTH上的MySQL 2.7 for Python 2.7是64位

时间:2022-09-19 07:59:01

Here's my problem: I can't Get MySQLdb for python working. Most of the other posts regarding this have cited having different architectures of MySQL/Python. I checked, and they're both 64 bit. I have Python 2.7.2 (standard OS X) and the latest MySQL, OS X 10.8.2.

这是我的问题:我无法获取MySQLdb for python工作。关于此的大多数其他帖子都引用了MySQL / Python的不同架构。我查了一下,他们都是64位。我有Python 2.7.2(标准OS X)和最新的MySQL,OS X 10.8.2。

my original error logs:

我的原始错误日志:

Trying to import MySQL db gives me this error:

尝试导入MySQL数据库给我这个错误:

  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

This might be helpful as well, the console output while I install mysql-python 1.2.4b4

这可能也有帮助,我安装mysql-python 1.2.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

2 个解决方案

#1


13  

I THINK I GOT IT! Here's what I did.

我认为我得到了它!这就是我做的。

OK this has been extremely frustrating.

好吧,这非常令人沮丧。

What finally made it work was doing this in the terminal :

最终使它工作的是在终端中执行此操作:

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

But there was alot of other stuff before that. I mixed the directions from two sources:

但在此之前还有很多其他的东西。我把两个来源的指示混合在一起:

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

如何在Mac OS X上安装MySQLdb(Python数据访问库到MySQL)?和http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/

I used the first to clean python and change the build files… I used the second to add 64 bit flags to install and build…

我用第一个来清理python并更改构建文件......我用第二个来添加64位标志来安装和构建......

Then I used an answer at Error importing MySQLdb in Python 2.7.2 on Mac OSx 10.8.1 (which was the final thing that made it work.)

然后我在Mac OSx 10.8.1上使用错误导入Python 2.7.2中的错误答案(这是使其工作的最后一件事。)

to set me over the edge.

让我超越边缘。

I’m not sure exactly what made a difference because I did SO MANY THINGS. I deleted a bunch of stuff from the 2.7 python folder….and other things. But the only thing i can be sure of is that mixing the directions from those two sources made a difference. Thanks for all the help, guys….lol I hope this saves somebody a headache.

我不确定究竟是什么造成了影响因为我做了很多事情。我从2.7 python文件夹中删除了一堆东西......以及其他东西。但我唯一可以肯定的是,混合来自这两个来源的指示产生了不同。感谢所有的帮助,伙计...... .lol我希望这能让人头疼。

#2


0  

I have listed the 4 configuration impediments that i faced, I have listed them.

我列出了我遇到的4个配置障碍,我已经列出了它们。

export CFLAGS=-Qunused-arguments export CPPFLAGS=-Qunused-arguments installing command line tools from xcode preferences/downloads sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

export CFLAGS = -Qunused-arguments export CPPFLAGS = -Qunused-arguments从xcode preferences / downloads sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18安装命令行工具。 dylib

#1


13  

I THINK I GOT IT! Here's what I did.

我认为我得到了它!这就是我做的。

OK this has been extremely frustrating.

好吧,这非常令人沮丧。

What finally made it work was doing this in the terminal :

最终使它工作的是在终端中执行此操作:

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

But there was alot of other stuff before that. I mixed the directions from two sources:

但在此之前还有很多其他的东西。我把两个来源的指示混合在一起:

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

如何在Mac OS X上安装MySQLdb(Python数据访问库到MySQL)?和http://birdhouse.org/blog/2009/02/21/python-mysql-connections-on-mac-os/

I used the first to clean python and change the build files… I used the second to add 64 bit flags to install and build…

我用第一个来清理python并更改构建文件......我用第二个来添加64位标志来安装和构建......

Then I used an answer at Error importing MySQLdb in Python 2.7.2 on Mac OSx 10.8.1 (which was the final thing that made it work.)

然后我在Mac OSx 10.8.1上使用错误导入Python 2.7.2中的错误答案(这是使其工作的最后一件事。)

to set me over the edge.

让我超越边缘。

I’m not sure exactly what made a difference because I did SO MANY THINGS. I deleted a bunch of stuff from the 2.7 python folder….and other things. But the only thing i can be sure of is that mixing the directions from those two sources made a difference. Thanks for all the help, guys….lol I hope this saves somebody a headache.

我不确定究竟是什么造成了影响因为我做了很多事情。我从2.7 python文件夹中删除了一堆东西......以及其他东西。但我唯一可以肯定的是,混合来自这两个来源的指示产生了不同。感谢所有的帮助,伙计...... .lol我希望这能让人头疼。

#2


0  

I have listed the 4 configuration impediments that i faced, I have listed them.

我列出了我遇到的4个配置障碍,我已经列出了它们。

export CFLAGS=-Qunused-arguments export CPPFLAGS=-Qunused-arguments installing command line tools from xcode preferences/downloads sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

export CFLAGS = -Qunused-arguments export CPPFLAGS = -Qunused-arguments从xcode preferences / downloads sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18安装命令行工具。 dylib