[英]How can I import an package into a Kivy app using buildozer
I have created a kivy app in package using the structure: 我使用以下结构在软件包中创建了一个kivy应用程序:
.
├── bin
│ └── myapp-0.1-debug.apk
├── buildozer.spec
└── kivy_app
├── __init__.py
├── __main__.py
├── main.py
└── source
└── kivy_app.py
I wish to use some features contained in another package that I have written: 我希望使用我编写的另一个软件包中包含的一些功能:
.
└── python_pkg
├── __init__.py
└── source
└── version.py
The module version.py contains: 模块version.py包含:
VERSION = '0.0.1'
When I insert the line: 当我插入行时:
from python_pkg import VERSION
into kivy_app.py, it works perfectly in kivy on the PC. 进入kivy_app.py,它可以在PC上以kivy完美运行。
I have added python_pkg to the requirements line in buildozer.spec. 我已经在buildozer.spec的要求行中添加了python_pkg。
I can build an APK, but the application will not run on Android. 我可以构建一个APK,但是该应用程序将无法在Android上运行。 The logcat output at the point of failure is:
故障点的logcat输出为:
ImportError: cannot import name 'VERSION' from 'python_pkg' (/data/user/0/org.test.myapp/files/app/_python_bundle/site-packages/python_pkg/__init__.pyc)
The _
init _
.py module in python_pkg has the line: python_pkg中的
_
init _
.py模块包含以下行:
from python_pkg.source.version import VERSION
How must arrange the setup up so that it works? 如何安排设置使其起作用?
Thanks to @inclement I have a solution. 感谢@inclement我有一个解决方案。 I have created a symlink to python_pkg and placed it in the kivy_app directory.
我已经创建了一个指向python_pkg的符号链接,并将其放置在kivy_app目录中。 The structure of the application is now
现在应用程序的结构
.
├── bin
│ └── myapp-0.1-debug.apk
├── buildozer.spec
└── kivy_app
├── __init__.py
├── __main__.py
├── main.py
├── python_pkg -> /home/jeff/projects/kivy_pkg/python_pkg/python_pkg
└── source
└── kivy_app.py
The element python_pkg is not needed in the requirements line in buildozer.spec and I have removed it. buildozer.spec的需求行中不需要python_pkg元素,我已将其删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.