2012-11-27 38 views
1

我在Mac OSX 10.8(Mountain Lion)上,剛剛安裝了Python 3.2.3。致命錯誤:在升級到python 3.2並從virtualenv安裝某些模塊後找不到'string.h'文件

當使用Python版本從虛擬環境中安裝pycrypto:

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

我得到的錯誤:試圖安裝cryptacular時

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 

類似的事情發生。

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

I'ved添加一個符號鏈接到Xcode開發文件夾:

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

但都存在該文件夾中的MacOSX10.7.sdk MacOSX10.8.sdk(不MacOSX10。 6.sdk如上所需)。

我在系統中遺漏了什麼?我該如何告訴它使用其他SDK之一?

+0

你是如何安裝Python的?你有沒有安裝XCode?如果是這樣,你是否安裝了命令行工具? –

+0

我確實安裝了XCode,並且我從這個軟件包安裝了python http://www.python.org/ftp/python/3.2.3/python-3.2.3-macosx10.6.dmg –

+1

啓動XCode,打開'XCode ' - >'首選項...'並進入'Downloads'選項卡。在'Components'下,確保'Command Line Tools'已經安裝;這也會*在系統文件夾中安裝系統頭文件。 –

回答

4

得到它做的工作如下:

如上評論,確信命令行工具安裝,這也安裝了系統頭:

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

我固定的,這通過創建從它的符號鏈接到OSX 10.8環境僞造的OSX 10.6環境:

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

包安裝成功了。

相關問題