当前位置:网站首页>Problems and solutions in pyinstall packaging for pychart project
Problems and solutions in pyinstall packaging for pychart project
2022-06-30 10:58:00 【Kill bug duck】
1、 Download and install pyinstaller library
( One ) Direct command line installation
pip3 install pyinstaller
( Two ) Or download the package through the official website , Then install locally
2、 Use pyinstaller Command line packaging
( One ) For the entire project with dependent libraries, it is recommended to use -D The way , Contains the package directory , Including some dlls Application extension, etc . First -c There's a console , Again -w There is no need to pack the black window console ,logo.ico For custom exe Icon ,XXXX.py Main procedure py file . namely :
First use the following command line to package :
pyinstaller -D -c -i logo.ico XXXX.py
stay step 5 after , Then use the command line below to hide the black window , Pack again :
pyinstaller -D -w -i logo.ico XXXX.py
( Two ) You can also use -F To be packaged into a separate exe, Packing speed ratio -D A lot slower . The meaning of other documents is the same as ( One )
pyinstaller -F -c -i logo.ico XXXX.py ## Generate separate exe, -c There are black windows on the console
pyinstaller -F -w -i logo.ico XXXX.py ## Generate separate exe,-w No console black window
3、 When packaging with multithreaded files , Multiple windows need to appear at the same time , Therefore, you need to import in the main program multprocessing, That is, add the following statement to the main program .
import multiprocessing
.
.
.
if __name__ == "__main__":
#################### Multi thread packaging needs to be added at the beginning of the main function
multiprocessing.freeze_support()
4、 After packaging ,exe stay dist Under the folder . A summary of the problems :
(1)ModuleNotFoundError:No module name “xxx”
Cause analysis : This is the lack of third-party libraries xxx
resolvent : Can be in cmd perhaps pycharm Of Terminal For direct use pip Install this library
(2) appear Hidden import not found “xxx” and WARNING Tips
Cause analysis : Will not affect the normal operation of the program , You can ignore this warning
resolvent : Can be ignored
(3) Black window flashback
Cause analysis : Some libraries are not installed or packaged pyinstaller Some unnecessary libraries are forcibly packed .
resolvent : open .exe file , Solve the problem by checking the errors reported in the command window . such as :: Put some necessary input files in the project , Configuration files, etc. are placed in the and exe Under the same level directory .
5、 After solving the problems occurred in the runtime , Delete... From the project folder (pycache,build,dist,xxx.spec) file
6、 Finally, it will include exe Of documents dist After the folder is compressed into a compressed package , In this way, you can double-click on another computer to run .
【 Last , You can ignore this , But at present, the configuration generated by packaging is modified spec resolved 】
(1) During packaging ,WARNING Warning tips :
4377 WARNING: lib not found: torch_python.dll dependency of
D:\Software\Anaconda3\Path\envs\Yolov5-DeepSort-Pytorch\lib\site-packages\torch_C.cp38-win_amd64.pyd
4932 WARNING: lib not found: torch_cpu.dll dependency of
D:\Software\Anaconda3\Path\envs\Yolov5-DeepSort-Pytorch\lib\site-packages\torchvision_C.pyd
4936 WARNING: lib not found: c10_cuda.dll dependency of
D:\Software\Anaconda3\Path\envs\Yolov5-DeepSort-Pytorch\lib\site-packages\torchvision_C.pyd
4937 WARNING: lib not found: torch_cuda.dll dependency of
D:\Software\Anaconda3\Path\envs\Yolov5-DeepSort-Pytorch\lib\site-packages\torchvision_C.pyd
4938 WARNING: lib not found: c10.dll dependency of
D:\Software\Anaconda3\Path\envs\Yolov5-DeepSort-Pytorch\lib\site-packages\torchvision_C.pyd
(2) Modification method
Insert the following four lines .spec The configuration file :
for d in a.datas:
if '_C.cp38-win_amd64.pyd' in d[0]:
a.datas.remove(d)
break
(3) The details of the .spec The configuration file :
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['main.py'],
pathex=['D:\\Files'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
####################################add
for d in a.datas:
if '_C.cp38-win_amd64.pyd' in d[0]:
a.datas.remove(d)
break
####################################stop
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
After modifying the configuration file , Use the following command to compile exe file :
pyinstaller mult_car.spec
边栏推荐
猜你喜欢

Time complexity and space complexity

Pytorch Notebook. Nn. Batchnorm1d

透過華為軍團看科技之變(五):智慧園區

电商两位大佬花边新闻刷屏,代表电商回归正常,将有利于实体经济

Wireguard simple configuration

中国将强制统一充电接口,苹果如不低头,iPhone将被踢出中国市场

Dow Jones Industrial Average

Go zero micro Service Practice Series (VIII. How to handle tens of thousands of order requests per second)

微信推出图片大爆炸功能;苹果自研 5G 芯片或已失败;微软解决导致 Edge 停止响应的 bug|极客头条...

第一届中国数字藏品大会即将召开
随机推荐
js常见问题
软件测试工程师面试基础题(应届生和测试小菜必备)最基础的面试题
China will force a unified charging interface. If Apple does not bow its head, iPhone will be kicked out of the Chinese market
How can the sports app keep the end-to-side background alive to make the sports record more complete?
SGD has many improved forms. Why do most papers still use SGD?
20万奖金池!【阿里安全 × ICDM 2022】大规模电商图上的风险商品检测赛火热报名中!...
第一届中国数字藏品大会即将召开
Every time I look at my colleagues' interface documents, I get confused and have a lot of problems...
在IPhone12的推理延迟仅为1.6 ms!Snap等详析Transformer结构延迟,并用NAS搜出移动设备的高效网络结构...
pytorch 笔记:validation ,model.eval V.S torch.no_grad
pytorch 筆記 torch.nn.BatchNorm1d
运动App如何实现端侧后台保活,让运动记录更完整?
语音信号处理-基础(五):傅立叶变换
程序员需知的 59 个网站
The intelligent DNA molecular nano robot model is coming
DQN笔记
The number of users of the home-made self-developed system exceeded 400million, breaking the monopoly of American enterprises, and Google repented
Cp2112 teaching example of using USB to IIC communication
深潜Kotlin协程(十八):冷热数据流
05_ Node JS file management module FS