在Mac OS 10.6上使用不同的gcc版本重新安装python [英] Reinstalling python on Mac OS 10.6 with a different gcc version

查看:300
本文介绍了在Mac OS 10.6上使用不同的gcc版本重新安装python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图安装一个需要运行gcc 4.2的Python包。我的gcc正确地指向gcc-4.2,即。

  $ gcc -v 
使用内置规格。
目标:i686-apple-darwin10
配置为:/ 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
线程模型:posix
gcc版本4.2.1(Apple Inc. build 5664)


 

$ python
Python 2.5.4(r254:67917,Dec 23 2008,15:47:06)
[GCC 4.0.1(Apple Inc. build 5363)]在达尔文
输入help,copyright,credits或license以获取更多信息。

有没有什么方法可以在没有的情况下在GCC 4.2 上重新构建Python?我必须重新安装我所有的Python软件包?



我的操作系统是Mac OS 10.6。不能帮助我将gcc指向gcc-4.0 - 我需要使用gcc-4.2。

解决方案

在当前的OS X Pythons,Distutils试图确保C扩展模块是使用相同的GCC和 MACOSX_DEPLOYMENT_TARGET (ABI)作为Python解释器本身构建的。这确保了不会与底层系统库发生冲突。



但是,如果您使用的是OS X 10.6,那么您展示的Python版本不是苹果提供的Pythons,两者都是用gcc-4.2构建的。很可能你有一个老版本的python.org 2.5,它也安装了符号链接到 / usr / local / bin 中。

<$ p
$ / usr / bin / python -c'import sys; print(sys.version)'
2.6.1(r261:67515)$ p $ #OS X 10.6.4
$ / ,2010年2月11日,00:51:29)
[GCC 4.2.1(Apple Inc. build 5646)]
$ /usr/bin/python2.6 -c'import sys; print(sys (版本5646)]
$ /usr/bin/python2.5 -c'import sys; print(sys.version)'
2.5.4(r254:67916,2010年2月11日,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,2008年12月23日,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

哪个python 会告诉你哪个Pytho n正在被调用。或者使用你想要的解释器的绝对路径,或者改变你的shell PATH或者删除旧的Python 2.5。


I am trying to install a Python package that requires running gcc 4.2. My gcc is pointing correctly to gcc-4.2, i.e.

$ 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)

However, my python is built using gcc 4.0, i.e.

$ 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.

Is there any way I can re-build Python on GCC 4.2 without having to reinstall all my Python packages?

My operating system is Mac OS 10.6.

NOTE: It will not help me to just point gcc to gcc-4.0 -- I need to use gcc-4.2.

解决方案

On current OS X Pythons, Distutils tries to ensure that C extension modules are built using the same GCC and MACOSX_DEPLOYMENT_TARGET (ABI) as the Python interpreter itself was. This ensures that there won't be conflicts with the underlying system libraries.

But if you are on OS X 10.6, then the Python version you show is not one of the Apple-supplied Pythons, both of which are built with gcc-4.2. Chances are you have an older python.org 2.5 also installed with symlinks into /usr/local/bin.

# 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

which python will tell you which Python is being invoked. Either use an absolute path to the interpreter you want or change your shell PATH or remove the old Python 2.5.

这篇关于在Mac OS 10.6上使用不同的gcc版本重新安装python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆