我无法安装Python-MySQL,我已经尝试过easy_install,pip和sources .. 我总是得到同样的错误。这就是我得到的:
Matts-MacBook:Python matt$ sudo easy_install MySQL-python
Searching for MySQL-python
Reading https://pypi.python.org/simple/MySQL-python/
Best match: MySQL-python 1.2.5
Downloading https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python- 1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c
Processing MySQL-python-1.2.5.zip
Writing /tmp/easy_install-i14rIs/MySQL-python-1.2.5/setup.cfg
Running MySQL-python-1.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-i14rIs/MySQL- python-1.2.5/egg-dist-tmp-mG9d4K
clang: warning: -framework CrashReporterSupport: 'linker' input unused
In file included from _mysql.c:44:
/usr/local/mysql/include/my_config.h:349:11: warning: 'SIZEOF_SIZE_T' macro redefined
#define SIZEOF_SIZE_T SIZEOF_LONG
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:56:17: note:
previous definition is here
# define SIZEOF_SIZE_T 4
^In file included from _mysql.c:44:
/usr/local/mysql/include/my_config.h:443:9: warning: 'HAVE_WCSCOLL' macro redefined
#define HAVE_WCSCOLL
^
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:912:9: note:
previous definition is here
#define HAVE_WCSCOLL 1
^
_mysql.c:1589:10: warning: comparison of unsigned expression < 0 is always false
[-Wtautological-compare]
if (how < 0 || how >= sizeof(row_converters)) {
~~~ ^ ~
3 warnings generated.
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.Internal.sdk/System/Library/PrivateFrameworks'
ld: framework not found CrashReporterSupport
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: Setup script exited with error: command 'cc' failed with exit status 1
答案 0 :(得分:15)
我已经解决了以下问题:
安装OSX command line tools后,安装MySQL-python。
$ xcode-select --install
$ sudo pip install MySQL-python
(发出三条警告信息,但是,“成功安装MySQL-python”......)
“导入MySQLdb”错误(“找不到图像”错误)已通过以下方式解决:
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/
我的环境,“OSX Yosemite,mysql 5.6.21,Python 2.7.8”。
祝你好运。答案 1 :(得分:2)
建议使用pip
代替easy-install
,因为这是更高级的解决方案。请参阅here了解原因。
由于您也遇到了XCode错误,因此可能没有安装OSX命令行工具。它们是编译MySQL-python
所必需的。您可以在登录后从Apple下载它们。
如果您仍然遇到错误,请通过homebrew安装mysql-client
。 brew install mysql --client-only
答案 2 :(得分:0)
首先通过自制软件安装mysql。对于自制软件安装,请参阅此链接 http://coolestguidesontheplanet.com/installing-homebrew-os-x-yosemite-10-10-package-manager-unix-apps/ 然后
pip uninstall MySQL-python
brew install mysql
pip install MySQL-python