编译时出错覆盖率.py在MacOSX上

2024-05-19 17:07:40 发布

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

我试图在运行当前macosx10.6.7的MacBook上安装coverage 3.4。这是我的错误:

$ easy_install coverage
install_dir /Users/jammon/workspace/myproject/lib/python2.7/site-packages/
Searching for coverage
Reading http://pypi.python.org/simple/coverage/
Reading http://nedbatchelder.com/code/modules/coverage.html
Reading http://nedbatchelder.com/code/coverage
Reading http://nedbatchelder.com/code/coverage/3.4b1
Reading http://nedbatchelder.com/code/coverage/3.4b2
Best match: coverage 3.4
Downloading http://pypi.python.org/packages/source/c/coverage/coverage-3.4.tar.gz#md5=46782809578c8fd29912c124d2420842
Processing coverage-3.4.tar.gz
Running coverage-3.4/setup.py -q bdist_egg --dist-dir /var/folders/10/10P5vwX-Ghmkg8s25PMr3E+++TI/-Tmp-/easy_install-UcskZB/coverage-3.4/egg-dist-tmp-QCs3YS
no previously-included directories found matching 'test'
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
                 from coverage/tracer.c:3:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
                 from coverage/tracer.c:3:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/10/10P5vwX-Ghmkg8s25PMr3E+++TI/-Tmp-//ccAYGjpc.out
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1

有人能理解吗?我只是不明白怎么了。或者我如何解决它。
非常感谢任何帮助。在

更新:
在内德的评论之后,我用easy_install -vv coverage尝试了一下;结果没有太大不同:

^{pr2}$

据我所知,我是用标准的方式从源代码编译python的,它不是二进制的发行版。我试过有没有virtualenv。在


Tags: installfromcomhttpincludelibrarycoveragecode
3条回答

最新版本的XCode取消了对编译到旧的PowerPC(PPC)体系结构的支持。不幸的是,Mac上的Python通常仍然试图为PPC和x86构建C扩展。为了解决这个问题,可以使用前缀命令,比如'设置.py“安装”或“轻松安装”,ARCHFLAGS设置仅包括要为其生成的体系结构:

ARCHFLAGS="-arch i386 -arch x86_64" easy_install coverage

经过大量的google搜索,我在this blogpost and the comments中找到了一个对我有用的解决方案:我删除了/Developer/SDKs/MacOSX10.4u.sdk,然后安装coverage(和reportlab,它显示了相同的问题)正如预期的那样工作。在

据我所知,在gcc的某些版本中,stdarg.h的处理发生了变化,导致了所描述的问题。在

或者,您可以use ActivePython来避免compile things yourself的需要:

$ pypm install coverage
The following packages will be installed into "~/Library/Python/2.7" (2.7):
 coverage-3.4
Get: [pypm-free.activestate.com] coverage 3.4
Installing coverage-3.4                                  
Fixing script ~/Library/Python/2.7/bin/coverage
$

相关问题 更多 >