Python Forum
pyinstaller not create single exe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: pyinstaller not create single exe (/thread-4388.html)



pyinstaller not create single exe - buran - Aug-12-2017

following this thread
https://python-forum.io/Thread-Have-you-used-pynsist
I decided to try pyinstaller. I want single exe + my config.ini file, but I get a bunch of files, despite that I specify --onefile option.

Output:
c:\Dropbox\TMS\dist\tms (tmspython) λ dir  Volume in drive C is Acer  Volume Serial Number is 10E4-092B  Directory of c:\Dropbox\TMS\dist\tms 12/08/2017  18:19    <DIR>          . 12/08/2017  18:19    <DIR>          .. 12/08/2017  17:29            12,640 api-ms-win-crt-conio-l1-1-0.dll 12/08/2017  17:29            15,712 api-ms-win-crt-convert-l1-1-0.dll 12/08/2017  17:29            12,128 api-ms-win-crt-environment-l1-1-0.dll 12/08/2017  17:29            13,664 api-ms-win-crt-filesystem-l1-1-0.dll 12/08/2017  17:29            12,640 api-ms-win-crt-heap-l1-1-0.dll 12/08/2017  17:29            12,128 api-ms-win-crt-locale-l1-1-0.dll 12/08/2017  17:29            22,368 api-ms-win-crt-math-l1-1-0.dll 12/08/2017  17:29            12,640 api-ms-win-crt-process-l1-1-0.dll 12/08/2017  17:29            16,224 api-ms-win-crt-runtime-l1-1-0.dll 12/08/2017  17:29            17,760 api-ms-win-crt-stdio-l1-1-0.dll 12/08/2017  17:29            17,760 api-ms-win-crt-string-l1-1-0.dll 12/08/2017  17:29            14,176 api-ms-win-crt-time-l1-1-0.dll 12/08/2017  17:29            12,128 api-ms-win-crt-utility-l1-1-0.dll 12/08/2017  18:19           758,193 base_library.zip 12/08/2017  16:31            11,984 config.ini 12/08/2017  17:29           773,968 MSVCR100.dll 12/08/2017  17:29           154,392 pyexpat.pyd 12/08/2017  17:29         3,122,176 python35.dll 12/08/2017  17:29           104,960 pywintypes35.dll 12/08/2017  17:29            19,736 select.pyd 12/08/2017  18:19         1,379,167 tms.exe 12/08/2017  18:19               695 tms.exe.manifest 12/08/2017  17:29         1,150,784 ucrtbase.dll 12/08/2017  17:29           861,976 unicodedata.pyd 12/08/2017  17:29            96,768 win32api.pyd 12/08/2017  17:29            73,496 _bz2.pyd 12/08/2017  17:29         1,035,032 _hashlib.pyd 12/08/2017  17:29           148,760 _lzma.pyd 12/08/2017  17:29            58,136 _socket.pyd 12/08/2017  17:29         1,464,600 _ssl.pyd               30 File(s)     11,406,791 bytes                2 Dir(s)  334,447,407,104 bytes free
any advise?

apart from not being single exe, it works just fine.


RE: pyinstaller not create single exe - snippsat - Aug-12-2017

What command do you use?
Should be pyinstaller -F --onefile your.py
After it should be one your.exe file in dist folder.


RE: pyinstaller not create single exe - buran - Aug-12-2017

Hm...
I was trying
pyinstaller --onefile myfile.spec and pyinstaller -F myfile.spec
Note, myfile.spec was created first by running pyinstaller myfile.py  (without --onefile option, because this was recommended - create one folder, then if it works - one file) and the I changed it to include the config.ini, like this
# -*- mode: python -*-

block_cipher = None


a = Analysis(['tms.py'],
             pathex=['c:\\Dropbox\\TMS'],
             binaries=,
             datas=[('config.ini', '.') ],
             hiddenimports=,
             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='tms',
          debug=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='tms')
after

now running again with --onefile: pyinstaller --onefile myfile.py it creates following spec file
# -*- mode: python -*-

block_cipher = None


a = Analysis(['tms.py'],
             pathex=['c:\\Dropbox\\TMS'],
             binaries=,
             datas=[('config.ini','.')],
             hiddenimports=,
             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,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='tms',
          debug=False,
          strip=False,
          upx=True,
          console=True )
as a result onefile exe is created. note that coll part is missing - this was my mistake.
However it does not include config.ini in the dist folder - even after I added config.ini in a.datas and run pyinstaller with .spec file .I have to move it myself.
Thanks.


RE: pyinstaller not create single exe - hbknjr - Aug-13-2017

Make sure the config.ini file path is given relative to the spec file.
Something like:
data's = [('folder/config.ini','.')]
you can also try and replace
'.'
with some foldername to see if that folder is created or not.