Python Forum
pyinstaller not create single exe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyinstaller not create single exe
#1
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.
Reply
#2
What command do you use?
Should be pyinstaller -F --onefile your.py
After it should be one your.exe file in dist folder.
Reply
#3
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.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Create multiple/single csv file for each sql records mg24 6 1,388 Sep-29-2022, 08:06 AM
Last Post: buran
  problem with pyinstaller to create an executable file atlass218 0 2,567 May-15-2021, 11:01 AM
Last Post: atlass218
  Pyinstaller create this error :“File ”multiprocessing\connection.py“, line 691 Formationgrowthhacking 2 3,619 Apr-30-2020, 10:26 AM
Last Post: buran
  PyInstaller, how to create library folder instead of library.zip file ? harun2525 2 4,792 May-06-2017, 11:29 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020