不能在Mac Mavericks上安装python mysql库吗?

时间:2022-02-09 20:52:54

It was working like a charm before the update from Mountain Lion.

在《美洲狮》更新之前,它就像一种魅力。

After the update it is broken and I cannot get the environment up again.

更新后,它被破坏了,我不能再恢复环境了。

Does anybody know how to fix this?

有人知道怎么解决这个问题吗?

The error is bolded, below.

错误是粗体的,下面。

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

UPDATE:

更新:

As suggested, I've added

作为建议,我补充道

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

出口CFLAGS = -Qunused-arguments出口CPPFLAGS = -Qunused-arguments

But it changed the error to

但它改变了错误。

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

I just chmoded this directory to allow writing and it worked :) This is due to mixing macports, easy_install and pip... shame on me.

我只是在这个目录下进行了修改,以允许写入和工作:)这是由于混合了macports、easy_install和pip……可耻的是我。

2 个解决方案

#1


40  

The problem is due to changes introduced in Xcode 5.1 and due to the way the Apple-supplied system Python 2.7 is built. Try adding these environment variable values before running pip:

问题在于Xcode 5.1中引入的更改,以及由于苹果提供的系统Python 2.7的构建方式。尝试在运行pip之前添加这些环境变量值:

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

See clang error: unknown argument: '-mno-fused-madd' (python package installation failure) for more information.

查看clang错误:未知参数:“-mno-fused-madd”(python包安装失败),以获得更多信息。

UPDATE [2014-05-16]: As expected, Apple has fixed this problem with updated system Pythons (2.7, 2.6, and 2.5) in OS X 10.9.3 so the workaround is no longer necessary when using the latest Mavericks and Xcode 5.1+. However, as of now, the workaround is still required for OS X 10.8.x (Mountain Lion, currently 10.8.5) if you are using Xcode 5.1+ there.

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

#2


0  

Building on Ned's answer:

大楼内德的回答是:

Since I don't want to use sudo to install packages (I am using virtual environments) or affect my golbal environment, I added the two variables to the single execution of pip install:

由于我不想使用sudo来安装包(我正在使用虚拟环境)或影响我的golbal环境,所以我将两个变量添加到pip安装的单个执行中:

CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install -r requirements.txt

CFLAGS=-去群发的参数。

#1


40  

The problem is due to changes introduced in Xcode 5.1 and due to the way the Apple-supplied system Python 2.7 is built. Try adding these environment variable values before running pip:

问题在于Xcode 5.1中引入的更改,以及由于苹果提供的系统Python 2.7的构建方式。尝试在运行pip之前添加这些环境变量值:

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

See clang error: unknown argument: '-mno-fused-madd' (python package installation failure) for more information.

查看clang错误:未知参数:“-mno-fused-madd”(python包安装失败),以获得更多信息。

UPDATE [2014-05-16]: As expected, Apple has fixed this problem with updated system Pythons (2.7, 2.6, and 2.5) in OS X 10.9.3 so the workaround is no longer necessary when using the latest Mavericks and Xcode 5.1+. However, as of now, the workaround is still required for OS X 10.8.x (Mountain Lion, currently 10.8.5) if you are using Xcode 5.1+ there.

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

#2


0  

Building on Ned's answer:

大楼内德的回答是:

Since I don't want to use sudo to install packages (I am using virtual environments) or affect my golbal environment, I added the two variables to the single execution of pip install:

由于我不想使用sudo来安装包(我正在使用虚拟环境)或影响我的golbal环境,所以我将两个变量添加到pip安装的单个执行中:

CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments pip install -r requirements.txt

CFLAGS=-去群发的参数。