简体   繁体   English

使用不同的gcc版本在Mac OS 10.6上重新安装python

[英]Reinstalling python on Mac OS 10.6 with a different gcc version

I am trying to install a Python package that requires running gcc 4.2. 我正在尝试安装需要运行gcc 4.2的Python包。 My gcc is pointing correctly to gcc-4.2, ie 我的gcc正确指向gcc-4.2,即

$ 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, ie 但是,我的python是使用gcc 4.0构建的,即

$ 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? 有没有什么办法可以在GCC 4.2上重新构建Python 无需重新安装我的所有Python包?

My operating system is Mac OS 10.6. 我的操作系统是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. 注意:将gcc指向gcc-4.0无法帮助我 - 我需要使用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. 在当前的OS X Pythons上,Distutils尝试确保使用与Python解释器本身相同的GCC和MACOSX_DEPLOYMENT_TARGET (ABI)构建C扩展模块。 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. 但是如果你使用的是OS X 10.6,那么你展示的Python版本不是Apple提供的Pythons之一,它们都是用gcc-4.2构建的。 Chances are you have an older python.org 2.5 also installed with symlinks into /usr/local/bin . 有可能你有一个较旧的python.org 2.5也安装了符号链接到/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. which python会告诉你正在调用哪个Python。 Either use an absolute path to the interpreter you want or change your shell PATH or remove the old Python 2.5. 使用所需解释器的绝对路径或更改shell PATH或删除旧的Python 2.5。

This is most likely an issue with distutils, you shouldn't need to recompile python, or reinstall any packages. 这很可能是distutils的问题,您不需要重新编译python或重新安装任何软件包。

Have you checked to see what version your CC environment variable is set to? 您是否检查过CC环境变量的版本? It may very well still be set to 4.0. 它可能仍然设置为4.0。 You can try: 你可以试试:

export CC=gcc-4.2
python setup.py build

You could also take a look at: 你也可以看看:

/Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/config/Makefile

Which is where distutils gets its build settings from. distutils从哪里获取其构建设置。

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

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