gpt4 book ai didi

pygobject - 为 Python 3.6 安装 py3cairo

转载 作者:行者123 更新时间:2023-12-05 06:40:38 24 4
gpt4 key购买 nike

我正在尝试安装 pygobject,但依赖项之一是 py3cairo。我已经安装它用于 Python 3.4,但现在我想将它用于 Python 3.6。

我知道我可以使用 sudo apt-get install python3-cairo 安装它,但它说它已经安装了:

$ sudo apt-get install python3-cairo
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-cairo is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

但是,

Python 3.6.0 (default, Feb 20 2017, 17:34:58) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gi'
>>> import cairo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cairo'
>>> quit()
brandon@bjd2385:~/Downloads$ python3.4
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> import cairo

尝试从源代码构建/安装它是丑陋的,因为我遇到了所有种类的问题:

$ PYTHON="python3.6" ./waf configure
./options()
Setting top to : /home/brandon/Downloads/pycairo-1.10.0
Setting out to : /home/brandon/Downloads/pycairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : python3.6
python executable 'python3.6' different from sys.executable '/usr/local/bin/python3.6'
Checking for python version : (3, 6, 0, 'final', 0)
Traceback (most recent call last):
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Scripting.py", line 93, in waf_entry_point
run_commands()
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Scripting.py", line 145, in run_commands
run_command(cmd_name)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Scripting.py", line 138, in run_command
ctx.execute()
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Configure.py", line 124, in execute
super(ConfigurationContext,self).execute()
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Context.py", line 87, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Context.py", line 127, in recurse
user_function(self)
File "/home/brandon/Downloads/pycairo-1.10.0/wscript", line 29, in configure
ctx.check_python_headers()
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Configure.py", line 217, in fun
return f(*k,**kw)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Tools/python.py", line 146, in check_python_headers
result=conf.check(lib=name,uselib='PYEMBED',libpath=path,mandatory=False,msg='Checking for library %s in LIBDIR'%name)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Configure.py", line 217, in fun
return f(*k,**kw)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Tools/c_config.py", line 357, in check
ret=self.run_c_code(*k,**kw)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Configure.py", line 217, in fun
return f(*k,**kw)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Tools/c_config.py", line 435, in run_c_code
bld.compile()
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Build.py", line 190, in compile
self.store()
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Utils.py", line 300, in f
ret=fun(*k,**kw)
File "/home/brandon/Downloads/pycairo-1.10.0/.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6/waflib/Build.py", line 164, in store
cPickle.dump(data,f)
AttributeError: Can't pickle local object 'Context.__init__.<locals>.node_class'
Checking for library python3.6 in LIBDIR :

如何安装 py3cairo 并克服这些问题?

最佳答案

我正在尝试做同样的事情,在 Slackware 14.2 上用 python3.6 编译 pycairo。我得到和你一样的错误,并且提到的各种 waf 补丁都没有工作。

我确实在这个追求中取得了进步。 slackware-current 发行版有一个似乎可以运行的 waf 脚本。它位于 http://ftp.slackware.com/pub/slackware/slackware-current/source/l/pycairo/

您提到的上述错误在此脚本中丢失,但当它尝试编译时 cairomodule.c 中出现错误时弹出另一个错误。

slackware-current 构建几乎成功了,但仍然因编译错误而失败。也许对库有更多经验的人可以修复它。

关于pygobject - 为 Python 3.6 安装 py3cairo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42357970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com