gpt4 book ai didi

python - fatal error : 'string.h' file not found after upgrading to python 3. 2 并从 virtualenv 安装某些模块

转载 作者:太空宇宙 更新时间:2023-11-04 10:51:25 26 4
gpt4 key购买 nike

我在 Mac OSX 10.8 (Mountain Lion) 上,刚刚安装了 Python 3.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

尝试安装 cryptacular 时会发生类似的事情。

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

我在 xcode 开发人员文件夹中添加了一个符号链接(symbolic link):

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

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

我的系统中是否缺少任何内容?我如何告诉它使用其他 SDK 之一?

最佳答案

通过执行以下操作让它工作:

如上评论所述,确保安装了命令行工具,这也会安装系统 header :

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 中的说明,创建指向开发人员文件夹的符号链接(symbolic link):

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 有关

我通过创建从它到 OSX 10.8 环境的符号链接(symbolic link)来伪造 OSX 10.6 环境来解决这个问题:

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

包现在安装成功。

关于python - fatal error : 'string.h' file not found after upgrading to python 3. 2 并从 virtualenv 安装某些模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13588518/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com