致命错误:升级到python 3.2并从virtualenv安装某些模块后,找不到"string.h"文件 [英] fatal error: 'string.h' file not found after upgrading to python 3.2 and installing certain modules from a virtualenv
问题描述
我在Mac OSX 10.8(Mountain Lion)上安装了Python 3.2.3.
I'm on Mac OSX 10.8 (Mountain Lion) and have just installed Python 3.2.3.
使用该版本的python在虚拟环境中安装pycrypto时:
When installing pycrypto from a virtual environment using that version of python:
$ 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
尝试安装密码系统时,也会发生类似的事情.
Similar thing happens when attempting to install cryptacular.
我已将符号链接添加到xcode开发人员文件夹:
I'ved added a symlink to the xcode developer folder:
$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer
但该文件夹中存在的所有文件都是MacOSX10.7.sdk MacOSX10.8.sdk(不是上面需要的MacOSX10.6.sdk).
but all that exists in that folder are MacOSX10.7.sdk MacOSX10.8.sdk (not MacOSX10.6.sdk as needed above).
我在系统中缺少任何内容吗?如何告诉它使用其他SDK之一?
Am I missing anything in my system? How can I tell it to use one of the other SDKs?
推荐答案
通过执行以下操作使其生效:
Got it to work by doing the following:
如上面的注释中所述,请确保已安装命令行工具,该命令行工具还安装了系统头文件:
As in the comment above, made sure the Command Line Tools are installed, which also installs the system headers:
启动Xcode,打开Xcode-> Preferences ...,然后转到Downloads选项卡.在组件"下,确保已安装命令行工具".这还将在系统文件夹中安装系统头文件.
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.
按照中的说明进行操作这个答案,创建指向开发人员文件夹的符号链接:
As instructed in this answer, create a symbolic link to the developer folder:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer
但是,仍然出现错误消息:
However, still go the error message:
Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk
这与问题有关,Python 3.2假定您正在使用Mac OSX 10.6
我通过在OSX 10.6环境中创建到OSX 10.8环境的符号链接来伪造此问题,从而解决了此问题:
I fixed, this by faking the OSX 10.6 environment by creating a symbolic link from it to the OSX 10.8 environment:
sudo ln -s /Developer/SDKs/MacOSX10.8.sdk MacOSX10.6.sdk
包现在已成功安装.
这篇关于致命错误:升级到python 3.2并从virtualenv安装某些模块后,找不到"string.h"文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!