問題描述
我正在嘗試構(gòu)建一個基于 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
我有一個用于構(gòu)建可分發(fā)版本的 PyInstaller 規(guī)范文件.這個版本在我的機器上運行良好,但不幸的是在其他機器上不行.使用 -v 開關(guān)在dist"版本中運行解釋器,似乎當我在我的機器上運行可分發(fā)文件時,navigationdrawer 組件實際上并不是來自我的構(gòu)建文件夾.所有其他導入顯示如下:
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 動態(tài)加載
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、系統(tǒng) 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
這將在當前目錄中創(chuàng)建一個 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.
這篇關(guān)于PyInstaller 中的 Kivy Garden - 試圖跟蹤導入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!