简体   繁体   English

无法在Mac OSX上安装py2cairo

[英]Cannot Install py2cairo on Mac OSX

I am trying to install py2cairo on a framework build (Mac OSX Lion) of python 2.7.3 using brew. 我正在尝试使用brew在python 2.7.3的框架构建(Mac OSX Lion)上安装py2cairo。 I have been unsuccessful this far. 到目前为止,我一直没有成功。

First, I tried a simple 首先,我尝试了一个简单的

brew install py2cairo

This seems to work only on a non-framework build of python. 这似乎只适用于python的非框架构建。 When I do this on my framework build python faults as soon as I import cairo with an incompatible binary error. 当我使用不兼容的二进制错误导入cairo时,我在我的框架上执行此操作构建python错误。

Second, I have tried to build it myself by grabbing it from github and issuing: 其次,我试图通过从github抓取它并发布:

python waf configure

This fails with: 这失败了:

Checking for library python2.7           : not found 
Checking for library python2.7           : not found 
Checking for library python2.7           : not found 
Checking for library python27            : not found 
Checking for program python2.7-config    : /usr/local/Cellar/python/2.7.3/bin/python2.7-   config 
Checking for header Python.h             : Could not find the python development headers 
The configuration failed
(complete log in /Users/tobin/tmp/py2cairo/build_directory/config.log)

I have tried everything at: How to install PyCairo 1.10 on Mac OSX with default python but none of this has helped. 我已经尝试了一切: 如何使用默认的python在Mac OSX上安装PyCairo 1.10,但这些都没有帮助。

It appears to me that this may be failing to find python2.7 library and header file since it is a framework build. 在我看来,这可能无法找到python2.7库和头文件,因为它是一个框架构建。 Is that possible? 那可能吗? I was looking at the brew formula and it appears that framework builds do not get --enable-share set at build time. 我正在研究brew公式,看起来框架构建在构建时没有得到--enable-share set。 I'm not sure if that is relevant here - but maybe one possibility. 我不确定这是否相关 - 但也许是一种可能性。

Anyone other insights would be great. 任何其他见解都会很棒。 Thanks in advance. 提前致谢。

UPDATE: 更新:

I discovered that the inability to build py2cairo had to do with the use of the "-march=native" flag by gcc. 我发现无法构建py2cairo与gcc使用“-march = native”标志有关。 gcc (4.2.1) on Mac OSX has issues with this. Mac OSX上的gcc(4.2.1)存在此问题。 I then reinstalled gcc as well as python. 然后我重新安装了gcc以及python。 Afterwards when building py2cairo with waf - it was getting "-march=core2" and everything built. 之后用waf构建py2cairo时 - 得到了“-march = core2”并且所有内容都已构建完成。

Unfortunately, not all is good yet. 不幸的是,并非一切都很好。 I get the same error when I import cairo from my build that I got from the brew version (as mentioned above). 当我从brew版本导入cairo时,我得到了同样的错误(如上所述)。 The exact error message is: 确切的错误消息是:

>>> import cairo
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap: 6

and then python exits. 然后python退出。

It would now seem that the issue is related to the framework build of python. 现在看来这个问题与python的框架构建有关。 I tested it without a framework build and it worked fine. 我没有框架构建测试它,它工作正常。

So as to not leave this question dangling ... I wanted to follow up with my resolution and learning points: 为了不让这个问题悬而未决......我想跟进我的决议和学习要点:

  1. As noted above there was an incompatibility with my version of OSX and a gcc compile flag called -march=native. 如上所述,与我的OSX版本和名为-march = native的gcc编译标志不兼容。 In a later version it was coming up as -march=core2. 在后来的版本中它出现了-march = core2。 This pretty much fixed itself with compiler/version changes after cleaning up my machine. 在清理我的机器后,这几乎修复了编译器/版本的变化。

  2. For years I have had quite a mess with all of my various MAC OSX installs - and accepting the "migration option". 多年来,我对所有各种MAC OSX安装都非常混乱 - 并且接受了“迁移选项”。 Two machines ago - I installed the python binaries for versions 2.4, and 2.5, Then eventually went to macports for various reasons. 两台机器之前 - 我为版本2.4和2.5安装了python二进制文件,然后由于各种原因最终进入了macports。 Then eventually went to homebrew. 然后最终去了自制软件。 When I went to homebrew I tried to clean things up by hand (but of course this can be challenging). 当我去自制软件时,我试图用手清理东西(但当然这可能很有挑战性)。 To make matters worse - everytime I have gotten a new mac (2 times) in the last 6 years I take "the migration install" option and this pushes the mess forward and makes it worse. 更糟糕的是 - 每次我在过去的6年中获得一个新的mac(2次)时,我会选择“迁移安装”选项,这会让事情变得更加糟糕。 So as I started looking into things further - I had various installs of python, with different versions - mac-native, python-native, mac ports, homebrew, and probably even others too on my system. 所以当我开始进一步研究时 - 我有各种各样的python安装,有不同的版本 - mac-native,python-native,mac ports,homebrew,甚至可能在我的系统上也是如此。 So my best guess is that cairo was somehow finding one of these and trying to build against it. 所以我最好的猜测是,cairo以某种方式找到其中一个,并试图建立它。

I finally solved this by deleting a bunch of old python installs by hand and then starting over with a fresh virtualenv and homebrew install of python 2.7. 我终于通过手工删除一堆旧的python安装,然后重新开始使用新的virtualenv和自制的python 2.7安装来解决这个问题。

WARNING: I don't think that this is the smartest way to go. 警告:我认为这不是最明智的选择。 I was careful not to delete a version of Python that I thought came native with OSX Lion (I think it is 2.6) - but it is not clear how it may potentially effect some other things that may have depended on older mac installs of python. 我小心翼翼地不删除我认为是OSX Lion原生的Python版本(我认为它是2.6) - 但目前尚不清楚它可能会影响其他一些可能依赖于旧版mac安装的python。 I ended up deleting a 2.3, a 2.4, and two different 2.5s - along with various links in some places. 我最终删除了2.3,2.4和两个不同的2.5 - 以及某些地方的各种链接。 WHAT A MESS! 真是一团糟! Unless you are absolutely sure of what it is you are doing (which I was not) I would not suggest this approach. 除非你完全确定你在做什么(我不是这样),否则我不会建议这种做法。 I was basically trying to kill 6 years of python install crud that has collected. 我基本上试图杀死已经收集的6年的python安装crud。

To be safe I probably should have started with a fresh OSX Lion install and then added my homebrew version and went from there. 为了安全起见,我可能应该从一个全新的OSX Lion安装开始,然后添加我的自制软件版本并从那里开始。 I will likely do this in the near future. 我很可能会在不久的将来这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM