当前位置: 首页 > 工具软件 > KivEnt > 使用案例 >

python3无法启动_无法启动Kivent并使用python 3运行

段干飞翔
2023-12-01

我试图在我的游戏中添加一些物理特性,但是很难让“ Kivent”和symunk运行。我认为一切都正确构建,但示例仅以python 2开头,而不以python3开头。

我收到以下错误消息:

mic@lin:~/python/kivy-kivent-12766f1/examples/4_adding_physics_objects> python3 main.py

[INFO ] [Logger ] Record log in /home/mic/.kiv/logs/kivy_16-01-26_48.txt

[INFO ] [Kivy ] v1.9.1

[INFO ] [Python ] v3.4.1 (default, May 23 2014, 17:48:28) [GCC]

[INFO ] [Factory ] 179 symbols loaded

[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)

[INFO ] [Window ] Provider: pygame(['window_egl_rpi'] ignored)

[INFO ] [GL ] OpenGL version

[INFO ] [GL ] OpenGL vendor

[INFO ] [GL ] OpenGL renderer

[INFO ] [GL ] OpenGL parsed version: 3, 0

[INFO ] [GL ] Shading version

[INFO ] [GL ] Texture max size <8192>

[INFO ] [GL ] Texture max units <32>

[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked

[INFO ] [OSC ] using for socket

Traceback (most recent call last):

File "main.py", line 8, in

import kivent_cymunk

File "/home/mic/python/kivy-kivent-12766f1/examples/4_adding_physics_objects/kivent_cymunk/__init__.py", line 1, in

from . import physics

ImportError: dynamic module does not define init function (PyInit_physics)

我整天都在搜索,但没有找到任何答案。仅Kivent核心可以工作,因此cymunk或kivent_cymunk必须是一个问题。我在使用python3构建这些模块时遇到了一些问题,因此,如果您有很好的建议来安装这些构建,也将很欢迎。

使用python3设置kivent_cymunk的错误是:

building 'kivent_cymunk.physics' extension

gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/usr/include/python3.4m -c kivent_cymunk/physics.c -o build/temp.linux-x86_64-3.4/kivent_cymunk/physics.o -std=c99 -ffast-math

In file included from kivent_cymunk/chipmunk/chipmunk.h:116:0,

from kivent_cymunk/physics.c:253:

kivent_cymunk/chipmunk/constraints/cpConstraint.h: In function ‘cpConstraintActivateBodies’:

kivent_cymunk/chipmunk/constraints/cpConstraint.h:94:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

cpBody *b = constraint->b; if(b) cpBodyActivate(b);

^

cc1: some warnings being treated as errors

error: command 'gcc' failed with exit status 1

我的系统是:OpenSuse 13.2。

我希望我能够解释这个问题,任何人都可以提供帮助。

提前致谢!

解决方案

因此,经过数小时的编译和复制,我终于找到了答案。

在发现之后,发现cymunk编译不正确非常容易。问题是,使用python3的编译器已将

-Werror=declaration-after-statement

使用python 2时未设置。要使用python 3正确编译cymunk和kivent_cymunk,我必须添加

-Wno-error=declaration-after-statement

到setup.py中的“ extra_compile_args”。之后,一切工作都很好(除了很多警告)。

有谁知道为什么这些声明那么糟糕?还是为什么gcc编译器对python 2和3具有不同的参数?

我希望我可以用这个答案节省很多工作。

最好,男

 类似资料: