【发布时间】:2023-04-01 06:31:01
【问题描述】:
刚安装XCode 4.3,现在无法安装mysql-python包。我使用 OS X Lion 10.7.4、XCode 4.3、自制软件,它们都是几个小时前安装的。使用自制的 python 2.7.3、mysql 5.5.25
这是输出:
(lukasz) ~ > pip install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
building '_mysql' extension
/usr/bin/gcc-4.2 -fno-strict-aliasing -Os -w -pipe -march=native -Qunused-arguments -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/Cellar/mysql/5.5.25/include -I/usr/local/Cellar/python/2.7.3/include/python2.7 -c _mysql.c -o build/temp.macosx-10.4-x86_64-2.7/_mysql.o -Qunused-arguments -g
_mysql.c:1: error: bad value (native) for -march= switch
_mysql.c:1: error: bad value (native) for -mtune= switch
error: command '/usr/bin/gcc-4.2' failed with exit status 1
Complete output from command /usr/local/Cellar/python/2.7.3/bin/python -c "import setuptools;__file__='/Users/lukasz/build/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/lv/p8rbhkk559x1337twh8flq0r0000gn/T/pip-Bvu67T-record/install-record.txt:
running install
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.4-x86_64-2.7/MySQLdb
running build_ext
building '_mysql' extension
/usr/bin/gcc-4.2 -fno-strict-aliasing -Os -w -pipe -march=native -Qunused-arguments -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/Cellar/mysql/5.5.25/include -I/usr/local/Cellar/python/2.7.3/include/python2.7 -c _mysql.c -o build/temp.macosx-10.4-x86_64-2.7/_mysql.o -Qunused-arguments -g
_mysql.c:1: error: bad value (native) for -march= switch
_mysql.c:1: error: bad value (native) for -mtune= switch
error: command '/usr/bin/gcc-4.2' failed with exit status 1
----------------------------------------
Command /usr/local/Cellar/python/2.7.3/bin/python -c "import setuptools;__file__='/Users/lukasz/build/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/lv/p8rbhkk559x1337twh8flq0r0000gn/T/pip-Bvu67T-record/install-record.txt failed with error code 1 in /Users/lukasz/build/MySQL-python
Storing complete log in /Users/lukasz/.pip/pip.log
(lukasz) ~ >
Mysql 是用 homebrew 安装的,没有问题:
(lukasz) ~ > brew info mysql
mysql 5.5.25
http://dev.mysql.com/doc/refman/5.5/en/
Depends on: cmake, readline, pidof
/usr/local/Cellar/mysql/5.5.25 (6382 files, 222M) *
fatal: Not a git repository (or any of the parent directories): .git
https://github.com//homebrew/commits/master/Library/Formula/mysql.rb
有没有办法手动更改 march 标志?
更新:
哦,我还安装了 命令行工具(Xcode -> 首选项 -> 下载),它显然为 gcc-4.2 创建了链接:
(lukasz) ~ > which gcc-4.2
/usr/bin/gcc-4.2
(lukasz) ~ > ls -l `which gcc-4.2`
lrwxr-xr-x 1 root wheel 12 12 Jun 01:36 /usr/bin/gcc-4.2 -> /usr/bin/gcc
(lukasz) ~ > gcc-4.2 --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
...
【问题讨论】:
-
Xcode 4.3 不提供
gcc-4.2
,因此您似乎正在使用从其他来源安装的编译器。gcc-4.2 --version
说什么? -
@NedDeily,似乎命令行工具创建了那个链接 (Xcode>Preferences>Downloads ...) (lukasz) ~ > 其中 gcc-4.2 /usr/bin/gcc-4.2 (lukasz) ~ > ls -l
which gcc-4.2
lrwxr-xr-x 1 根轮 12 月 12 日 01:36 /usr/bin/gcc-4.2 -> /usr/bin/gcc (lukasz) ~ > gcc-4.2 --version i686- apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (基于 Apple Inc. build 5658) (LLVM build 2336.9.00) ... -
据我所知,Apple 的命令行工具没有为 gcc-4.2 安装符号链接(我刚刚验证了刚刚发布的 Xcode 4.3.3 及其命令行工具没有改变)。但它所链接的 llvm-gcc 是最新的 Apple gcc。所以这不是问题。这些标志通常不适用于任何 Apple 编译器;他们通常使用'-arch'。它可能是由杂散的环境变量设置注入的,例如 CFLAGS 或 LDFLAGS。另外,通过运行 mysql_config 检查 mysql 配置中记录的内容; MySQL-python 看了一下。
标签:
python
mysql
xcode
mysql-python
homebrew
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:无法使用 XCode 4.3/homebrew 编译 mysql-python - Python技术站