使用Python开发的程序,运行速度上不太满意,碰巧看到赖勇浩CSDN博客中翻译的Cython三分钟入门。得空便开始着手尝试,半天未果。
问题一大堆,比如:
- OS下设置环境变量;
- Clang(/klæŋ/)安装;
OS下终端里设置临时环境变量的方法比较容易:
export PATH=$PATH:'app/bin'
OS设置永久环境变量,网上搜了一篇,没太搞明白,但起作用了:Mac下设置环境变量
编译Clang需要GCC,GCC我在XCode安装目录下找到了:
/Applications/Xcode.app/Contents/Developer/usr/bin
按照《结构化编译器前端Clang介绍》折腾半天,最终也没能编译成功。
回头再去XCode安装目录:
Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
找到了,果断复制了Clang至:
/Applications/Xcode.app/Contents/Developer/usr/bin
也不知道,合不合适,但终端里输入Clang终于有反应了
cd Cython-0.17.3
python setup.py build
阻力继续:
running build_py
running build_ext
building 'Cython.Plex.Scanners' extension
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c Cython/Plex/Scanners.c -o build/temp.macosx-10.8-intel-2.7/Cython/Plex/Scanners.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
Cython/Plex/Scanners.c:4:10: fatal error: 'Python.h' file not found
#include "Python.h"
^
1 error generated.
error: command 'clang' failed with exit status 1
stackoverflow上有个最佳答案:
sudo apt-get install python-dev
mac 里没有 apt-get 这个工具,傻眼。。。
其实还在Xcode目录中:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include
找到了“Python.h”,怎么让 python setup.py build 时知道呢?再傻眼。。。
没有师傅指导。。。
难免走弯路。。。
会遇到些稀奇古怪的东西,完全搞不清状况。。。
我看到了这篇文章:
《Fatal Error:studio.h File Not Found》
"Command Line Tools" 的 comment:
"Before installing, note that from within Terminal you can use the XCRUN tool to launch compilers and other tools embedded within the Xcode application. Use the XCODE-SELECT tool to define which version of Xcode is active. Type "man xcrun" from within Terminal to find out more.
Downloading this package will install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools."
再次打开终端:输入gcc,输入clang,就这么简单,绕这么大弯。
python setup.py build 有些警告
sudo python setup.py install
结束!
分享到:
相关推荐
OS X Mountain Lion 10.8.2 VMware Image VMware 镜像 AMD Interl CPU 都可用,AMD已测试,镜像可直接打开,无需引导
Moutain Lion 10.8.2 10.7.5 懒人版,实测有效
苹果最新推出ml10.8.2,用迅雷下载资源多速度快。
mac 10.8.2 懒人版
ESRI ArcGIS Desktop 10.8.2图文安装教程
AMD的mountain lion 10.8.2内核amd_kernel.zip
WIN7下VMware9.0.1虚拟机安装MacOSX10.8.2Lion教程
mac10.8.2OSInstall(MBR) OSInstall.mpkg
karen lion mac 10.8.2
本人是Dell E6400,安装的是 10.8.2懒人版,除无线网卡外,其他完美驱动。 把所有和这个里面有冲突的驱动都删掉,然后粘贴过去,不要直接覆盖。 安装教程参考:http://benyouhui.it168.com/thread-2867663-1-1.html
OSInstall(MBR)+mpkg(10.8.0+10.8.1+10.8.2).
编译实在太麻烦了,环境是 MacOs 10.8.2,php5.3.15,下载后放在适当的目录后配置下php.ini即可
OSInstall(MBR)+OSInstall.mpkg(10.9.GM),可将OS X Mavericks安装到MBR分区上的补丁。
10.8.2 RTL81xx网卡驱动 Kext
mac系统 10.8.2 这里给出种子,给需要的童鞋
Portrait Professional v10.8.2破解版下载
苹果OS X 10.8官方原版dmg镜像,建议安装黑苹果的朋友们最好安装原版镜像
这个是最强白版本....安装后不要启动程序, 将其中的破解文件和语言文件复制到安装目录下,然后启动程序,在"file-settings...-Language"中选择frence, 确定后退出Portrait Professional,再启动即可显示中文界面.
mac10.8.2OS Nv9系显卡驱动
vmware 8.0/9.0 安装 mac os10.8 完整教程(附VMware补丁) 按照教程依次下载所需要软件,VMware补丁不需要下载,已经附带了,亲测已安装好mac os10.8.2~ 祝各位,安装顺利!