Python3.7 Pyinstaller 打包Face_Recognition程序

问题

直接使用pyinstaller -F test.py 进行打包,之后运行exe会报错
image

解决方法

将dat文件打包到exe中
修改spec文件

# -*- mode: python -*-

block_cipher = None

face_models = [
('.\\face_recognition_models\\models\\dlib_face_recognition_resnet_model_v1.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\mmod_human_face_detector.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\shape_predictor_5_face_landmarks.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\shape_predictor_68_face_landmarks.dat', './face_recognition_models/models'),
]

a = Analysis(['xxx.py'],
             pathex=['C:\\Users\\pc\\Desktop\\test'],
             binaries=face_models,
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='xxx',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )
posted @ 2021-08-09 11:15  不能说的秘密  阅读(306)  评论(0编辑  收藏  举报