Pyinstaller无法将我的dll复制到MEIPA

2024-09-30 12:15:35 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我尝试不停地用我的python脚本创建一个可执行文件。。。在

在调试模式下运行时:

pyinstaller emotions.spec

一切正常,没有警告,没有错误。。。只有一条奇怪的信息:

12047 INFO: distutils: retargeting to non-venv dir 'C:\Dev\Python35\Lib\distutils'

我不知道这是否说明什么

我的规范文件:

^{pr2}$

Im使用: virtualenv上的Python 3.5.0; Pyinstaller 3.3.1版

当我试图运行/dist/emotions/emotions.exe时,我得到以下错误:

[940] PyInstaller Bootloader 3.x
[940] LOADER: executable is C:\Users\tijuk\Projects\Vision\dist\emotions\emotions.exe
[940] LOADER: homepath is C:\Users\tijuk\Projects\Vision\dist\emotions
[940] LOADER: _MEIPASS2 is NULL
[940] LOADER: archivename is C:\Users\tijuk\Projects\Vision\dist\emotions\emotions.exe
[940] LOADER: Extracting binaries
[940] LOADER: Executing self as child
[940] LOADER: set _MEIPASS2 to C:\Users\tijuk\AppData\Local\Temp\_MEI9402
[940] LOADER: Setting up to run child
[940] LOADER: Creating child process
[940] LOADER: Waiting for child process to finish...
[3280] PyInstaller Bootloader 3.x
[3280] LOADER: executable is C:\Users\tijuk\Projects\Vision\dist\emotions\emotions.exe
[3280] LOADER: homepath is C:\Users\tijuk\Projects\Vision\dist\emotions
[3280] LOADER: _MEIPASS2 is C:\Users\tijuk\AppData\Local\Temp\_MEI9402
[3280] LOADER: archivename is C:\Users\tijuk\Projects\Vision\dist\emotions\emotions.exe
[3280] LOADER: SetDllDirectory(C:\Users\tijuk\AppData\Local\Temp\_MEI9402)
[3280] LOADER: Already in the child - running user's code.
[3280] LOADER: Python library: C:\Users\tijuk\AppData\Local\Temp\_MEI9402\python35.dll
Error loading Python DLL 'C:\Users\tijuk\AppData\Local\Temp\_MEI9402\python35.dll'.
LoadLibrary: Não foi possível encontrar o módulo especificado.
[940] LOADER: Back to parent (RC: -1)
[940] LOADER: Doing cleanup
[940] LOADER: Freeing archive status for C:\Users\tijuk\Projects\Vision\dist\emotions\emotions.exe

LoadLibrary: NÒo foi possÝvel encontrar o m¾dulo especificado

手段

LoadLibrary: It was not possible to find the specified module

如果我改为Python3.6,我会得到相同的结果,但是改为python36.dll。在

我查过这个…\Appdata\Local\Temp_MEI9402,里面还有其他文件,比如数据pyinstaller也应该捆绑在一起。在

我看过其他的问题,但它们要么没有帮助,要么我不明白如何使用提供的“修复” 例如这个: Bundling data files with PyInstaller (--onefile)

我不知道该把写在答案上的代码片段复制到哪里。在

注意:我在这个项目中使用tensorflow,所以我需要Python3.5或3.6

注2:我已经试过py2exe了

提前非常感谢!在


Tags: tochildislocaldistloaderexeusers
1条回答
网友
1楼 · 发布于 2024-09-30 12:15:35

这里帖子的主人。。。所以。。。我不知道为什么会被修复,但我将它改回了.spec文件的旧版本:

# -*- mode: python -*-

block_cipher = None

a = Analysis(['emotions.py'],
             pathex=['.','C:\\Users\\tijuk\\Envs\\vis_p3.5\\Lib\\site-packages\\scipy\\extra-dll'],
             binaries=[],
             datas=[
                ('checkpoints\\epoch_75.hdf5','.\\checkpoints'),
                ('haarcascade_frontalface_default.xml','.'),
                ('png\\*','.\\png'),
                ('gifs\\sad\\*', '.\\gifs\\sad'),
                ('gifs\\happy\\*', '.\\gifs\\happy'),
                ('gifs\\neutral\\*', '.\\gifs\\neutral'),
                ('gifs\\scared\\*', '.\\gifs\\scared'),
                ('gifs\\sunglass\\*', '.\\gifs\\sunglass'),
                ('gifs\\surprised\\*', '.\\gifs\\surprised')
                ],
             hiddenimports=['scipy._lib.messagestream'],
             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,
          exclude_binaries=True,
          name='emotions',
          debug=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='emotions')

我跑了:

^{pr2}$

希望这对某人有帮助

相关问题 更多 >

    热门问题