我正在尝试构建一个基于 Kivy 的 Python 项目.它通过导入使用来自 Kivy Garden 的 NavigationDrawer 组件:
I have a Kivy-based Python project that I'm trying to build. It uses the NavigationDrawer component from Kivy Garden, through an import:
从 kivy.garden.navigationdrawer 导入 NavigationDrawer
from kivy.garden.navigationdrawer import NavigationDrawer
我有一个用于构建可分发版本的 PyInstaller 规范文件.这个版本在我的机器上运行良好,但不幸的是在其他机器上不行.使用 -v 开关在dist"版本中运行解释器,似乎当我在我的机器上运行可分发文件时,navigationdrawer 组件实际上并不是来自我的构建文件夹.所有其他导入显示如下:
I have a PyInstaller spec file for it which builds a distributable version. This version works well on my machine, but unfortunately not on other machines. Running the interpreter in the 'dist' version with the -v switch, it appears that when I run the distributable on my machine, the navigationdrawer component is not actually coming from inside my build folder. All the other imports show something like:
import kivy.graphics.gl_instructions # 从 C:UsersmemyappdistRACECA~1kivy.graphics.gl_instructions.pyd 动态加载
import kivy.graphics.gl_instructions # dynamically loaded from C:UsersmemyappdistRACECA~1kivy.graphics.gl_instructions.pyd
但是 navigationdrawer 导入说:
But the navigationdrawer import says:
导入 kivy.garden.navigationdrawer
import kivy.garden.navigationdrawer
"""目录 C:Usersme.kivygardengarden.navigationdrawerC:Usersme.kivygardengarden.navigationdrawer\__init__.pyc 匹配 C:Usersme.kivygardengarden.navigationdrawer\__init__.pyimport kivy.garden.navigationdrawer # 预编译自 C:Usersme.kivygardengarden.navigationdrawer\__init__.pyc"""
"""directory C:Usersme.kivygardengarden.navigationdrawer C:Usersme.kivygardengarden.navigationdrawer\__init__.pyc matches C:Usersme.kivygardengarden.navigationdrawer\__init__.py import kivy.garden.navigationdrawer # precompiled from C:Usersme.kivygardengarden.navigationdrawer\__init__.pyc"""
但是不!我不希望您从 c:users 导入它们.我希望它们像所有其他导入一样被很好地复制到我的 dist 文件夹中.我尝试将 c:usersme 添加到 PyInstaller 的 pathex、系统 PATH 和 PYTHONPATH 中,但没有任何乐趣.有人有什么想法吗?
But noo! I don't want you to import them from c:users. I want them to get nicely copied into my dist folder like all the other imports. I've tried adding c:usersme to PyInstaller's pathex, the system PATH and PYTHONPATH without any joy. Anyone have any ideas?
尝试将您的 garden 包安装到您的应用中.即
Try installing your garden packages into your app. i.e.
garden install --app navigationdrawer
这将在当前目录中创建一个 libs/garden 文件夹,并将 garden 包放入其中,这应该更容易包含.
This will create a libs/garden folder inside the current directory and place the garden packages in there, which should make it easier to include.
这篇关于PyInstaller 中的 Kivy Garden - 试图跟踪导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!