Pyinstaller 打包踩坑指南

创建一个新的环境用于打包,这样不会导致打包exe太大
遇到的问题及正确解决方案:
1、[WinError 6] 句柄无效

Traceback (most recent call last):
  ...
  File "subprocess.py", line 383, in run
  File "subprocess.py", line 640, in __init__
  File "subprocess.py", line 850, in _get_handles
OSError: [WinError 6] 句柄无效。

修改image.py中的参数为:


import_cv2_proc = subprocess.Popen(
        [interpreter, "-c", "import cv2"],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True, 
        stdin=subprocess.PIPE,)

2、ImportError: OpenCV loader: missing configuration file: [‘config.py‘]. 报错解决

PyInstaller -F -w -i logo.ico PaddleStain.py --paths=“D:\software\anaconda3\envs\paddle\Lib\site-packages\cv2”

加上 --path 参数

3、打包得到exe文件后在dist文件夹下,要将配置文件也copy到dist文件夹下,程序才可以正常运行

你可能感兴趣的:(python,python)