致命错误:升级到Python3.2并从virtualen安装某些模块后,找不到“string.h”文件

2024-05-23 18:08:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我在MacOSX10.8(MountainLion)上,刚刚安装了Python3.2.3。

使用该版本的python从虚拟环境安装pycrypto时:

$ virtualenv --no-site-packages -p /usr/local/bin/python3.2-32 venv
$ source venv/bin/activate
$ pip install pycrypto

我知道错误:

gcc-4.2 not found, using clang instead

building 'Crypto.Hash._MD2' extension

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk

Please check your Xcode installation

clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c src/MD2.c -o build/temp.macosx-10.6-intel-3.2/src/MD2.o

src/MD2.c:30:10: fatal error: 'string.h' file not found

#include <string.h>

         ^

1 error generated.

error: command 'clang' failed with exit status 1

在尝试安装cryptolar时也会发生类似的事情。

As of version 2.4, Pycrypto says it supports python 3.

我已经向xcode开发人员文件夹添加了符号链接:

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer

但该文件夹中的所有内容都是MacOSX10.7.sdk MacOSX10.8.sdk(而不是上面需要的MacOSX10.6.sdk)。

我的系统里有遗漏吗?我怎么能告诉它使用其他的sdk呢?


Tags: srcdeveloperbinvenvwithsdknoterror
1条回答
网友
1楼 · 发布于 2024-05-23 18:08:26

通过执行以下操作来实现:

如上面的注释所示,确保安装了命令行工具,该工具还安装了系统头:

Start Xcode, open Xcode -> Preferences... and go to the Downloads tab. Under Components make sure the Command Line Tools are installed; this will also install system headers in system folders.

按照this answer中的说明,创建指向开发人员文件夹的符号链接:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer

但是,仍然显示错误消息:

Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk

这与issue that Python 3.2 assumes you are using Mac OSX 10.6有关

我修复了这个问题,通过创建一个从OSX10.8环境到OSX10.6环境的符号链接来伪造OSX10.6环境:

sudo ln -s /Developer/SDKs/MacOSX10.8.sdk MacOSX10.6.sdk

包现在已成功安装。

相关问题 更多 >