简体   繁体   English

如何在 Ubuntu 10.04 上为 python 3 安装 pycairo

[英]how to install pycairo for python 3 on Ubuntu 10.04

i am trying to install pycairo 1.10.0 for use with my custom-build python 3.1.我正在尝试安装 pycairo 1.10.0 以与我的自定义构建 python 3.1 一起使用。 however,然而,

sudo /flower/bin/easy_install-3.1 pycairo

fails with失败了

XXX@XXXX:/adventures$ sudo /flower/bin/easy_install-3.1 pycairo
install_dir /flower/lib/python3.1/site-packages/
Searching for pycairo
Reading http://pypi.python.org/simple/pycairo/
Reading http://cairographics.org/pycairo
Best match: pycairo 1.10.0
Downloading http://cairographics.org/releases/pycairo-1.10.0.tar.bz2
Processing pycairo-1.10.0.tar.bz2
error: Couldn't find a setup script in /tmp/easy_install-zeG9HB/pycairo-1.10.0.tar.bz2

and indeed, there is no setup.py in the said download;实际上,上述下载中没有setup.py instead, the INSTALL says:相反, INSTALL说:

Install Procedure
-----------------
$ ./waf --help     # shows available waf options
$ ./waf configure  # use --prefix and --libdir if necessary
                   # --prefix=/usr --libdir=/usr/lib64  for Fedora 64-bit
$ ./waf build
$ ./waf install

Use
$ python3 ./waf ...
if you have python2 and python3 installed, and the default is python 2.


Testing
-------
See test/README

i understand that as telling me that i should我明白这告诉我我应该

sudo /flower/bin/python3.1 ./waf configure --prefix=/flower/pycairo/

or similar;或类似的; however, this leads to the following error:但是,这会导致以下错误:

  ./options()
Setting top to                           : /tmp/pycairo-1.10.0 
Setting out to                           : /tmp/pycairo-1.10.0/build_directory 
  ./configure()
Checking for 'gcc' (c compiler)          : ok 
Checking for program python              : /usr/bin/python 
python executable '/usr/bin/python' different from sys.executable '/flower/bin/python3.1'
Checking for python version              : (2, 6, 5, 'final', 0) 
The python version is too old, expecting (3, 1, 0)

so i went down into the source code;所以我深入研究了源代码; there is seemingly no way to tell this waf thingie that the targetted python version is simply the one it runs on itself, so i fumbled around and got as far as this:似乎没有办法告诉这个 waf 东西,目标waf版本只是它自己运行的版本,所以我摸索了一下,就这样了:

Checking for 'gcc' (c compiler)          : ok 
Checking for program python              : /usr/bin/python 
#############293 /flower/bin/python3.1
Checking for python version              : (3, 1, 2, 'final', 0) 
Checking for library python3.1 in LIBDIR : yes 
Checking for program python3.1-config    : not found 
Checking for program python-config-3.1   : not found 
Checking for header Python.h             : Could not find the python development headers 
Checking for []                          : not found 
The configuration failed

i do in fact have a file /flower/bin/python3.1-config so i don't get it.我实际上有一个文件/flower/bin/python3.1-config所以我不明白。 the python code that does all this is rather hard to handle.执行所有这些操作的 python 代码相当难以处理。

any suggestions how to go on?任何建议如何 go 上? is there a *.deb or similar ready for pycairo + python 3? pycairo + python 3 是否有*.deb或类似文件? couldn't find any.找不到。

By looking at the python.py file in that subdir I decided to try setting an environment var before executing the waf thru python3:通过查看该子目录中的 python.py 文件,我决定在通过 python3 执行 waf 之前尝试设置环境变量:
export PYTHON="python3"导出 Python=“python3”
And then the install mysteriously succeeded...然后安装就莫名其妙的成功了……

I'm using Ubuntu Karmic, but installing with python2.7 compiled from source, so this is a work around I found in my case.我正在使用 Ubuntu Karmic,但是使用从源代码编译的 python2.7 安装,所以这是我在我的案例中找到的解决方法。 I though it might be helpful, but please use caution.我虽然它可能会有所帮助,但请谨慎使用。

I found some discussion threads that has similar installation problems here我在这里发现了一些有类似安装问题的讨论线程

Although it's not the same python version, there are some flags which you can set for waf.虽然它不是同一个 python 版本,但您可以为 waf 设置一些标志。

I got past that Python.h part after using the following command使用以下命令后,我通过了 Python.h 部分

LDFLAGS="-lm -ldl -lutil" ./waf configure

As I have compiled from source python2.7, I need to reroute the paths with CFLAGS.正如我从源代码 python2.7 编译的那样,我需要使用 CFLAGS 重新路由路径。 The final command looks like this:最终命令如下所示:

CFLAGS="-l/usr/local/include/python2.7 -l/usr/local/bin" LDFLAGS="-lm -ldl -lutil" ./waf configure

I have no idea how the LDFLAGS work, so use with caution.我不知道 LDFLAGS 是如何工作的,所以请谨慎使用。

Alternatively (dangerous method), if you don't want to set the CFLAGS, I did do some symbolic-re-linking in the /local/bin of python to my python2.7, same with python-config to python2.7-config (if you installed from package manager, you might not need to do this)或者(危险的方法),如果您不想设置 CFLAGS,我确实在 python 的/local/bin中将一些符号重新链接到我的 python2.7,与 python-config 到 python2.7 相同-配置(如果您从 package 管理器安装,您可能不需要这样做)

This is clearly a bug in the pycairo installer, where it tries to figure out where the Python exe is (when what it should do is to simply use the Python exe that it is run with).这显然是 pycairo 安装程序中的一个错误,它试图找出 Python exe 在哪里(当它应该做的是简单地使用它运行的 Python exe 时)。

I tried to find it, but this code is using its own completely custom build system (it's not onvious why) and the code is laid out in a very weird way, astonishingly with major parts of the code hidden(!) in a directory called .waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6 and written in some of the most unreadable Python code I've ever seen.我试图找到它,但是这段代码使用了它自己的完全自定义的构建系统(这并不奇怪),并且代码的布局非常奇怪,令人惊讶的是,代码的主要部分隐藏在一个名为的目录中(!) .waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6并用我见过的一些最不可读的 Python 代码编写。 As such it would take me hours to understand this code and help you with what probably is a trivial bug.因此,我需要几个小时才能理解这段代码并帮助你解决可能是一个微不足道的错误。

If you really need this library I suggest you contact the author and ask him nicely if he can fix the bug.如果你真的需要这个库,我建议你联系作者并很好地询问他是否可以修复这个错误。

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

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