1

So I've trying non-stop to create an executable out of a python script I have...

When I run in debug mode:

pyinstaller emotions.spec

Everything runs just fine, no warnings, no errors... only a weird looking INFO line:

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

I dont know if this indicates anything

my spec file:

    # -*- 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')

Im using: Python 3.5.0 on a virtualenv & Pyinstaller 3.3.1

When I try to run /dist/emotions/emotions.exe I get the following error:

[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

means

LoadLibrary: It was not possible to find the specified module

If I change to Python3.6, I get the same thing, but for python36.dll instead.

I've looked up this ...\Appdata\Local\Temp_MEI9402 and there are other files in there, like the data pyinstaller should also bundle together.

I've looked on these other Questions but they either didnt help, or I couldnt understand how to use the 'fix' provided for example this one: Bundling data files with PyInstaller (--onefile)

Where I couldnt understand where I should copy those snippets of code written on most of the answers.

NOTE: Im using tensorflow on this project, so I need either Python3.5 or 3.6

NOTE2: I have already tried py2exe

Thank you very much in advance!

Alexandre Dias
  • 414
  • 4
  • 13

1 Answers1

2

Owner of the post here... So... I have no idea why it is fixed, but I changed it back to an older version of my .spec file:

# -*- 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')

And I ran:

pyinstaller --onedir emotions.spec

Hope this helps someone

Alexandre Dias
  • 414
  • 4
  • 13
  • The only difference I see between the two is that some values were `None` instead of being empty lists. – Guimoute Oct 13 '21 at 11:35