Pyinstaller无法将我的dll复制到MEIPASS

时间:2018-03-01 04:27:51

标签: python tensorflow exe pyinstaller

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

当我在调试模式下运行时:

pyinstaller emotions.spec

一切运行得很好,没有警告,没有错误......只有一个奇怪的INFO线:

  

12047 INFO:distutils:重定向到非venv dir   'C:\开发\ Python35 \ LIB \的distutils'

我不知道这是否表明任何事情

我的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','.'),
                ('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=None,
             runtime_hooks=None,
             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,
          exclude_binaries=True,
          name='emotions',
          debug=True,
          strip=False,
          upx=True,
          onedir=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='emotions')

我正在使用: 关于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可能包含的内容

装置

  

LoadLibrary:无法找到指定的模块

如果我改为Python3.6,我会得到同样的东西,但是对于python36.dll而言。

我查了一下这个... \ Appdata \ Local \ Temp_MEI9402并且还有其他文件,比如数据pyinstaller也应该捆绑在一起。

我已经查看了其他这些问题,但他们要么没有帮助,要么我无法理解如何使用提供的'修复' 例如这一个: Bundling data files with PyInstaller (--onefile)

我无法理解我应该在哪里复制那些写在大多数答案上的代码片段。

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

注2:我已经尝试过py2exe

非常感谢你!

1 个答案:

答案 0 :(得分:0)

这里的帖子的所有者......所以......我不知道为什么它被修复了,但我把它改回了我的.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')

我跑了:

pyinstaller --onedir emotions.spec

希望这有助于某人