小编典典

无法在Mac Mavericks上安装python mysql库

python

在Mountain Lion进行更新之前,它就像一种魅力。

更新后,它已损坏,我无法再次启动环境。

有人知道如何解决此问题吗?

该错误在下面以黑体显示。

fedorius@this:~$ pip install mysql-python
Downloading/unpacking mysql-python
  Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
  Running setup.py (path:/private/var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/pip_build_fedorius/mysql-python/setup.py) egg_info for package mysql-python

Installing collected packages: mysql-python
  Running setup.py install for mysql-python
    building '_mysql' extension
    cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64
    clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
    clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
    error: command 'cc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/pip_build_fedorius/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/pip-_yi6sy-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib.macosx-10.9-intel-2.7

copying _mysql_exceptions.py -> build/lib.macosx-10.9-intel-2.7

creating build/lib.macosx-10.9-intel-2.7/MySQLdb

copying MySQLdb/__init__.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb

copying MySQLdb/converters.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb

copying MySQLdb/connections.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb

copying MySQLdb/cursors.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb

copying MySQLdb/release.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb

copying MySQLdb/times.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb

creating build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-intel-2.7/MySQLdb/constants

running build_ext

building '_mysql' extension

creating build/temp.macosx-10.9-intel-2.7

cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing -arch x86_64

**clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1**

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/pip_build_fedorius/mysql-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/pip-_yi6sy-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/pip_build_fedorius/mysql-python
Storing debug log for failure in /var/folders/21/zjvwzn891jnf4rnp526y13200000gn/T/tmp5QBn55

更新:

按照建议,我添加了

导出CFLAGS =-带参数的参数导出CPPFLAGS =-带参数的参数

但是它将错误更改为

error: /Library/Python/2.7/site-packages/_mysql.so: Permission denied

我只是修改了这个目录以允许写入,并且它起作用了:)这是由于混合了macports,easy_install和pip …对我而言很可耻。


阅读 128

收藏
2020-12-20

共1个答案

小编典典

该问题是由于Xcode 5.1中引入的更改以及Apple提供的系统Python 2.7的构建方式所致。尝试在运行之前添加以下环境变量值pip

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

有关更多信息,请参见clang错误:未知参数:’-mno-fused-
madd’(python软件包安装失败)

更新[2014-05-16]:正如预期的那样,Apple已使用更新的系统Python(2.7、2.6和2.5)修复了此问题,OS X 10.9.3因此在使用最新的Mavericks和时不再需要解决方法Xcode 5.1+。但是,到目前为止,OS X 10.8.x如果您正在使用(Mountain Lion,当前为10.8.5),仍然需要解决方法Xcode 5.1+

2020-12-20