皮尼乌斯导入错误?运行 Kivy 的示例安卓程序期间的问题



>我用pip安装了kivi,pyjnius和jnius。

python.exe -m pip install pyjnius
python.exe -m pip install jnius

它已成功构建和安装。

我尝试运行 kivy 的一个例子:

'''
Compass example

This example is a demonstration of Hardware class usage.
But it has severals drawbacks, like using only the magnetic sensor, and
extrapolating values to get the orientation. The compass is absolutely not
accurate.
The right way would be to get the accelerometer + magnetic, and computer
everything according to the phone orientation. This is not the purpose of 
this
example right now.
You can compile it with::
./build.py --package org.test.compass --name compass 
--private ~/code/kivy/examples/android/compass 
--window --version 1.0 debug installd
'''

import kivy
kivy.require('1.7.0')
from jnius import autoclass
from kivy.app import App
from kivy.properties import NumericProperty
from kivy.clock import Clock
from kivy.vector import Vector
from kivy.animation import Animation
Hardware = autoclass('org.renpy.android.Hardware')

class CompassApp(App):
.
.
.

并得到错误:

[INFO   ] [Logger      ] Record log in C:UsersJanka.kivylogskivy_18-06- 
03_2.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) 
[MSC v.1900 32 bit (Intel)]
Traceback (most recent call last):
File "C:UsersJankaAppDataLocalProgramsPythonPython35-32sharekivy- 
examplesandroidcompassmain.py", line 25, in <module>
from jnius import autoclass
File "C:UsersJankaAppDataLocalProgramsPythonPython35-32libsite- 
packagesjnius__init__.py", line 12, in <module>
from .jnius import *  # noqa
ImportError: DLL load failed: The specified module could not be found.

我做错了什么?我是 kivy 的新手,只是想让它在给定的例子上工作。也许我需要在运行前编译它?

我不确定你的 pyjnius 是否正确编译。然而,更大的问题是你的pyjnius代码只能在Android上运行 - org.renpy.android.hardware在桌面上不存在。

pyjnius通常就是这种情况,尽管它可以在桌面上运行,但如果您只需要Android,那么将其放在那里就没有多大意义。我通常会通过在Android上运行时有条件地导入和使用pyjnius来解决此问题。

最新更新