我正在尝试安装需要运行gcc 4.2的Python包.我的gcc正确指向gcc-4.2,即
<code>$gcc -v Using built-in specs. Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5664~38/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5664) </code>
但是,我的python是使用gcc 4.0构建的,即
<code>$python Python 2.5.4 (r254:67917, Dec 23 2008, 15:47:06) [GCC 4.0.1 (Apple Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. </code>
有没有什么办法可以在GCC 4.2上重新构建Python而无需重新安装我的所有Python包?
我的操作系统是Mac OS 10.6.
注意:将gcc指向gcc-4.0无法帮助我 – 我需要使用gcc-4.2.
解决方法:
在当前的OS X Pythons上,Distutils尝试确保使用与Python解释器本身相同的GCC和MACOSX_DEPLOYMENT_TARGET(ABI)构建C扩展模块.这可确保不会与底层系统库发生冲突.
但是如果你使用的是OS X 10.6,那么你展示的Python版本不是Apple提供的Pythons之一,它们都是用gcc-4.2构建的.有可能你有一个较旧的python.org 2.5也安装了符号链接到/usr/local/bin.
<code># OS X 10.6.4 $/usr/bin/python -c 'import sys;print(sys.version)' 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] $/usr/bin/python2.6 -c 'import sys;print(sys.version)' # same as above 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] $/usr/bin/python2.5 -c 'import sys;print(sys.version)' 2.5.4 (r254:67916, Feb 11 2010, 00:50:55) [GCC 4.2.1 (Apple Inc. build 5646)] $/usr/local/bin/python2.5 -c 'import sys;print(sys.version);print(sys.executable)' 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python </code>
哪个python会告诉你正在调用哪个Python.使用所需解释器的绝对路径或更改shell PATH或删除旧的Python 2.5.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!