Paddle "import paddle.fluid as fluid" 打包成.exe在其他机器运行报错

qvsjd97n  于 2021-12-07  发布在  Java
关注(0)|答案(6)|浏览(577)

版本、环境信息:
1)paddlepaddle1.8.5 CPU版本
2) 系统环境:win10 家庭中文版 1903
3)python 3.7.6(Anaconda3)

predict_fun.py中第二行为"import paddle.fluid as fluid" ,用pyinstaller -D打包后无法运行,
之后添加\Anaconda3\Lib\site-packages\paddle\libs下的5个dll后能在本机器运行,
但是在别的电脑无法运行,报错信息如下

Traceback (most recent call last):
File "mainWindows.py", line 7, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "predict_fun.py", line 2, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle_init.py", line 37, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor\math.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\common_ops_import.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid
init.py", line 56, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib
init.py", line 27, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\core
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\core\config.py", line 19, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\prune
init.py", line 17, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\prune\prune_strategy.py", line 22, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize
init.py", line 390, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize_minimize.py", line 30, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize_trustregion_constr
init.py", line 4, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize_trustregion_constr\minimize_trustregion_constr.py", line 4, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg
init.py", line 116, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg\eigen
init.py", line 11, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg\eigen\arpack
init_.py", line 22, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg\eigen\arpack\arpack.py", line 45, in
ImportError: DLL load failed: 找不到指定的程序。
[17824] Failed to execute script mainWindows

06odsfpq

06odsfpq1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

yqlxgs2m

yqlxgs2m2#

问题补充:
打包前为了解决打包的.exe一直生成相同的子进程问题,按照https://github.com/PaddlePaddle/Paddle/pull/26200/files
对paddle/dataset/image.py进行了修改

o4hqfura

o4hqfura3#

打包后无法运行报错与移植到其他机器报错信息一致吗?

unhi4e5o

unhi4e5o4#

打包经历

1.添加site-package/paddle下的5个.dll前(本机):

Traceback (most recent call last):
File "mainWindows.py", line 7, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "predict_fun.py", line 2, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle_init.py", line 37, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor\math.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\common_ops_import.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid
init_.py", line 35, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\framework.py", line 35, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\core.py", line 273, in
File "paddle\fluid\core.py", line 243, in
ImportError: DLL load failed: 找不到指定的模块。

2.添加后:

生成的.exe不停生成同名子进程,无法运行

3.按照https://github.com/PaddlePaddle/Paddle/pull/26200/files

对paddle/dataset/image.py进行了修改后打包并添加paddle下.dll

Traceback (most recent call last):
File "mainWindows.py", line 7, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "predict_fun.py", line 2, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle
init*.py", line 37, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex
init*.py", line 15, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor
init*.py", line 15, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor\math.py", line 15, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\common_ops_import.py", line 15, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid
init*.py", line 56, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib
init*.py", line 27, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim
init*.py", line 15, in
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\core
init*.py", line 15, in
File "", line 983, in find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\core\config.py", line 19, in
File "", line 983, in find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\prune
init*.py", line 17, in
File "", line 983, in find_and_load
File "", line 967, in *find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\prune\prune_strategy.py", line 20, in
File "", line 983, in *find_and_load
File "", line 967, in *find_and_load_unlocked
File "", line 677, in *load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "prettytable
init*.py", line 43, in
File "pkg_resources
init*.py", line 482, in get_distribution
File "pkg_resources
init.py", line 358, in get_provider
File "pkg_resources
init.py", line 901, in require
File "pkg_resources
init.py", line 787, in resolve
pkg_resources.DistributionNotFound: The 'prettytable' distribution was not found
and is required by the application
[15612] Failed to execute script mainWindows***

4.mainWindows.py(需要打包的.py文件)同目录下新增一个hook-ctypes.macholib.py,

内容为:
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('prettytable')
重新打包

pyinstaller -D mainWindows.py --additional-hooks-dir=.

并添加paddle下.dll后,本机能运行
但别的机器(未安装paddlepaddle)

报错为:
Traceback (most recent call last):
File "mainWindows.py", line 7, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "predict_fun.py", line 2, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle_init.py", line 37, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\complex\tensor\math.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\common_ops_import.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid
init.py", line 56, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib
init.py", line 27, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\core
init.py", line 15, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\core\config.py", line 19, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\prune
init.py", line 17, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "paddle\fluid\contrib\slim\prune\prune_strategy.py", line 22, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize
init.py", line 390, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize_minimize.py", line 30, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize_trustregion_constr
init.py", line 4, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\optimize_trustregion_constr\minimize_trustregion_constr.py", line 4, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg
init.py", line 116, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg\eigen
init.py", line 11, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg\eigen\arpack
init_.py", line 22, in
File "PyInstaller\loader\pyimod03_importers.py", line 324, in exec_module
File "scipy\sparse\linalg\eigen\arpack\arpack.py", line 45, in
ImportError: DLL load failed: 找不到指定的程序。
[17824] Failed to execute script mainWindows

5. 单独写一个test.py测试了一下

import import paddle.fluid as fluid
if __name__ == '__main__':
    print("Hello.")

也有问题

wwwo4jvm

wwwo4jvm5#

这部分是指在移植机器上执行失败是吗?

neskvpey

neskvpey6#

@1771559253 感谢。打包这个实在是问题多多,之前那个多个同名线程的问题我是通过杀线程弄得

相关问题