前言

环境:python3.6.8
系统:ubuntu18.04

前期准备

创建hook文件

在pyinstaller的hook目录下(python根目录/lib/python3.6/site-packages/PyInstaller/hooks),创建以下两个文件:

# hook-paddle.py
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files("paddle")

# hook-paddlehub.py
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files("paddlehub")

解决进程无线启动问题

修改源码 python根目录/lib/python3.6/site-packages/paddle/dataset/image.py

libmklml_intel.so

当出现报错ImportError: libmklml_intel.so: cannot open shared object file: No such file or directory时,解决方法:安装mkl

pyinstaller打包命令

pyinstaller --exclude matplotlib \
	--hidden-import six \
	--hidden-import requests \
    --hidden-import shapely \
	--hidden-import pyclipper \
    --add-binary "python根目录/lib/python3.6/site-packages/paddle/libs:." \
	-p "/python根目录/lib/python3.6/site-packages" \
	--clean -c -F server.py

更多推荐

ubuntu下pyinstaller打包paddlehub