Python PyInstaller卡在“上”;建筑包装……”;导出单个.exe时
我写了一个kivy程序,我想通过pyinstaller将其导出到一个.exe文件中。我成功地导出到多个文件(标准选项),但当我将--onefile选项添加到pyinstaller时,进程被卡在一行上,上面说:Python PyInstaller卡在“上”;建筑包装……”;导出单个.exe时,python,compilation,kivy,pyinstaller,Python,Compilation,Kivy,Pyinstaller,我写了一个kivy程序,我想通过pyinstaller将其导出到一个.exe文件中。我成功地导出到多个文件(标准选项),但当我将--onefile选项添加到pyinstaller时,进程被卡在一行上,上面说: INFO: Building PKG (CArchive) out00-PKG.pkg 有人知道怎么解决吗?是时间问题还是我在出口过程中遗漏了什么 我的项目: 我使用的是python 3.6.4、kivy 1.9.0和pyinstaller 3.3.1。main.py和main.
INFO: Building PKG (CArchive) out00-PKG.pkg
有人知道怎么解决吗?是时间问题还是我在出口过程中遗漏了什么
我的项目:
我使用的是python 3.6.4、kivy 1.9.0和pyinstaller 3.3.1。main.py和main.kv文件(我只使用了2个文件)都在同一个文件夹中,从现在起我将称之为\project\u folder\文件夹。在同一文件夹中还有一个名为icon.ico的图标
我也在使用UPX(upx394a),它被下载到一个名为\UPX\U path\upx394a的文件夹中
首先,我用以下内容修改了main.py文件:
import kivy
import sys
import os
...
def resourcePath():
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS)
return os.path.join(os.path.abspath("."))
...
if __name__=='__main__':
kivy.resources.resource_add_path(resourcePath())
MainApp().run()
对于导出,我运行windows提示符;我移动到\project\u文件夹,然后使用以下内容导出:
pyinstaller main.py --onefile --clean -y --windowed --icon=icon.ico
--name MyApp --upx-dir=\upx_path\upx394a --exclude-module _tkinter
--exclude-module Tkinter --exclude-module enchant --exclude-module twisted
我在以下位置找到此选项:
以这种方式成功创建.spec文件后,我继续修改.spec文件以正确创建.exe:
一,
python -m PyInstaller MyApp.spec
在这里,在一些提示输出之后,pyinstaller被卡住了。我试着等待了一段时间,但什么也没发生
**我的代码:**
在这里我粘贴了我正在使用的代码,希望它能帮助:
1.main.py
# python 3.6.4
from kivy.config import Config
Config.set('input', 'mouse', 'mouse, multitouch_on_demand')
# set non resizable window, specify heigth and width
Config.set('graphics', 'resizable', False)
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '600')
Config.set('graphics', 'borderless', False)
import kivy
import sys
import os
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
# la funzione definita di seguito serve per esportazione in .exe
def resourcePath():
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS)
return os.path.join(os.path.abspath("."))
class RootWidget(FloatLayout):
pass
class MainApp(App):
def build(self):
return RootWidget()
if __name__=="__main__":
kivy.resources.resource_add_path(resourcePath()) # add this line
MainApp().run()
# File name: main.kv
#:kivy 1.9.0
#:set logo_image 'logo_1.png'
<CreditLabel@Label>: # custom class for credits window labels
size_hint: [.4, .1]
color: 1, 1, 1, 1
<RootWidget>:
TabbedPanel:
do_default_tab: False
tab_width: self.parent.width/5
background_color: 0, 0, 0, 1
TabbedPanelItem:
text: 'Benvenuto!'
color: 1, 0.5, 0, 1
FloatLayout:
Label:
size_hint: .4, .25
pos_hint: {'center_x': 0.5, 'center_y': 0.7}
text: 'Benvenuto in MyBaku!'
font_size: 40
color: 1, 0.5, 0, 1
Label:
size_hint: .6, .25
pos_hint: {'center_x': 0.5, 'center_y': 0.55}
text: 'Bentornato Gianpietro! Prenditi il tuo tempo per visualizzare le tue statistiche.'
font_size: 18
color: 1, 1, 1, 1
Label:
canvas:
Rectangle:
size: 80, 80
pos: self.right - (self.width * 0.15), self.top * 0.8
source: logo_image
TabbedPanelItem:
text: 'Questa notte...'
color: 1, 0.5, 0, 1
FloatLayout:
TabbedPanelItem:
text: 'Statistiche globali'
color: 1, 0.5, 0, 1
FloatLayout:
TabbedPanelItem:
text: 'Credits'
color: 1, 0.5, 0, 1
FloatLayout:
Label:
canvas:
Rectangle:
#:set coefficient .3
size: self.width * coefficient, self.width * coefficient
pos: self.center_x - (self.width * coefficient)/2, self.top * 0.5
source: logo_image
CreditLabel:
text: 'Software developed by Giampo (dev 0.1)'
pos_hint: {'center_x': .5, 'center_y': .45}
CreditLabel:
text: 'Written with Python 3.6.4 using kivy 1.9.0'
pos_hint: {'center_x': .5, 'center_y': .40}
CreditLabel:
text: 'Trento (Italy) - march 2018'
pos_hint: {'center_x': .5, 'center_y': .35}
#文件名:main.kv
#:kivy 1.9.0
#:设置logo_图像“logo_1.png”
:#学分窗口标签的自定义类
大小提示:[.4,.1]
颜色:1,1,1,1
:
选项卡面板:
do_default_选项卡:False
选项卡宽度:self.parent.width/5
背景颜色:0,0,0,1
选项卡式面板项目:
文字:“Benvenuto!”
颜色:1,0.5,0,1
浮动布局:
标签:
大小提示:.4,.25
位置提示:{'center_x':0.5,'center_y':0.7}
文字:“米巴库的本维努托!”
字体大小:40
颜色:1,0.5,0,1
标签:
大小提示:.6,.25
位置提示:{'center_x':0.5,'center_y':0.55}
文字:“Bentornato Gianpietro!每周二统计的可视化速度。”
字号:18
颜色:1,1,1,1
标签:
画布:
矩形:
尺码:80,80
位置:self.right-(self.width*0.15),self.top*0.8
资料来源:logo_图片
选项卡式面板项目:
文字:'questanotte…'
颜色:1,0.5,0,1
浮动布局:
选项卡式面板项目:
文字:“全球统计”
颜色:1,0.5,0,1
浮动布局:
选项卡式面板项目:
文字:“学分”
颜色:1,0.5,0,1
浮动布局:
标签:
画布:
矩形:
#:设定系数。3
尺寸:self.width*系数,self.width*系数
位置:self.center_x-(self.width*系数)/2,self.top*0.5
资料来源:logo_图片
信用标签:
文字:“Giampo开发的软件(开发版本0.1)”
位置提示:{'center_x':.5'center_y':.45}
信用标签:
text:“使用kivy 1.9.0使用Python 3.6.4编写”
位置提示:{'center_x':.5'center_y':.40}
信用标签:
文本:“特伦托(意大利)-2018年3月”
位置提示:{'center_x':.5'center_y':.35}
尝试删除现有的build和dist目录,看看它是否解决了问题,这个解决方案对我来说很有效,我在调用pyinstaller时也使用了完整路径,因为我有多个版本的python。我也有同样的问题,有同样的“信息”:。我忘记以管理员身份运行cmd…以这种方式运行后,它能够完成转换。您不必删除完整的内部版本和dist目录,只需删除其中与所需exe文件对应的文件夹。例如,删除build\testexe和dist\testexe。这将保存一些其他版本,以防您不需要我把他们存到别处去了。
# File name: main.kv
#:kivy 1.9.0
#:set logo_image 'logo_1.png'
<CreditLabel@Label>: # custom class for credits window labels
size_hint: [.4, .1]
color: 1, 1, 1, 1
<RootWidget>:
TabbedPanel:
do_default_tab: False
tab_width: self.parent.width/5
background_color: 0, 0, 0, 1
TabbedPanelItem:
text: 'Benvenuto!'
color: 1, 0.5, 0, 1
FloatLayout:
Label:
size_hint: .4, .25
pos_hint: {'center_x': 0.5, 'center_y': 0.7}
text: 'Benvenuto in MyBaku!'
font_size: 40
color: 1, 0.5, 0, 1
Label:
size_hint: .6, .25
pos_hint: {'center_x': 0.5, 'center_y': 0.55}
text: 'Bentornato Gianpietro! Prenditi il tuo tempo per visualizzare le tue statistiche.'
font_size: 18
color: 1, 1, 1, 1
Label:
canvas:
Rectangle:
size: 80, 80
pos: self.right - (self.width * 0.15), self.top * 0.8
source: logo_image
TabbedPanelItem:
text: 'Questa notte...'
color: 1, 0.5, 0, 1
FloatLayout:
TabbedPanelItem:
text: 'Statistiche globali'
color: 1, 0.5, 0, 1
FloatLayout:
TabbedPanelItem:
text: 'Credits'
color: 1, 0.5, 0, 1
FloatLayout:
Label:
canvas:
Rectangle:
#:set coefficient .3
size: self.width * coefficient, self.width * coefficient
pos: self.center_x - (self.width * coefficient)/2, self.top * 0.5
source: logo_image
CreditLabel:
text: 'Software developed by Giampo (dev 0.1)'
pos_hint: {'center_x': .5, 'center_y': .45}
CreditLabel:
text: 'Written with Python 3.6.4 using kivy 1.9.0'
pos_hint: {'center_x': .5, 'center_y': .40}
CreditLabel:
text: 'Trento (Italy) - march 2018'
pos_hint: {'center_x': .5, 'center_y': .35}