繁体   English   中英

尝试在Mac OS X Yosemite上安装MySQL-python时出错

[英]Getting Error trying to install MySQL-python on Mac OS X Yosemite

我收到错误叮当声:错误:未知参数:'-fabi-version = 2',当我尝试使用pip安装mysql-python时。

MacBook-Pro-de-Haruan:MySQL-python-1.2.5 haruan$ sudo -E pip install MySQL-python
The directory '/Users/haruan/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/haruan/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting MySQL-python
  Downloading MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 110kB 311kB/s 
Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python
    Complete output from command /usr/local/opt/python/bin/python2.7 -c "import setuptools, tokenize;__file__='/private/var/folders/sh/gl953xl12p3fl1k0lkw10_k00000gn/T/pip-build-ZBmISy/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/sh/gl953xl12p3fl1k0lkw10_k00000gn/T/pip-5RkJ0a-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.10-x86_64-2.7
    copying _mysql_exceptions.py -> build/lib.macosx-10.10-x86_64-2.7
    creating build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb
    creating build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.10-x86_64-2.7/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.10-x86_64-2.7
    clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Qunused-arguments -Qunused-arguments -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/Applications/XAMPP/xamppfiles/include -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.10-x86_64-2.7/_mysql.o -arch x86_64 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing
    clang: error: unknown argument: '-fabi-version=2'
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -c "import setuptools, tokenize;__file__='/private/var/folders/sh/gl953xl12p3fl1k0lkw10_k00000gn/T/pip-build-ZBmISy/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/sh/gl953xl12p3fl1k0lkw10_k00000gn/T/pip-5RkJ0a-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/sh/gl953xl12p3fl1k0lkw10_k00000gn/T/pip-build-ZBmISy/MySQL-python

我已经使用过:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
export ARCHFLAGS='-Wno-error=unused-command-line-argument-hard-error-in-future'

sudo -E ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install mysql-python

sudo -E ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip mysql-python

问题仍然存在。

我的Xcode是6.4版(6E35b),并且使用Mac OS X Yosemite

如果其他人遇到了这种情况,并且由于某种原因而不希望通过更改为其他MySQL安装来解决它,则有一个相对简单的解决方法。 我遇到了这个问题,试图针对Bitnami MAMP堆栈5.5版中包含的MySQL软件包编译mysqlclient。 您只需要调整安装,这样就不会将有问题的参数传递给编译器,如下所示:

  1. GitHub下载软件包
  2. 打开setup_posix.py文件
  3. 初始化extra_compile_args变量后(当前版本中的第58-59行),添加以下代码行: extra_compile_args.pop(extra_compile_args.index('-fabi-version=2'))
  4. 在包目录中,运行python setup.py install

为我工作。

我发现了问题,我安装了XAMPP,并且XAMPP上的mysql使用了该标志。 我通过Homebrew卸载了XAMPP并安装了mysql,现在一切正常。

我在使用Softaculous AMPPS时遇到了同样的问题。 根据上述来自Max的回复,我能够弄清楚如何解决该问题。

只需从“ cflags”中删除“ -fabi-version = 2”标志(本例中为122行)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM