Python Forum
Trouble making my first python .exe using pyinstaller.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble making my first python .exe using pyinstaller.
#1
I am trying to make a win 10 executable (.exe) from my helloworld.py script. I have installed pyinstall-3.2 and following the install document isn't so easy.
Any help getting this working will be appreciated.

PyInstaller is located at:
Quote:
c:\pyInstaller-3.2

helloworld.py and hellowworld.bat are both at:

Quote:c:\users\michael\desktop\helloworld\


Here is the Bat file
python c:\pyInstaller-3.2\Makespec.py --onefile --console --upx --tk helloworld.py
python c:\pyInstaller-3.2\PyInstaller\building\build_main.py helloworld.spec
pause
Here is helloworld.py
#!/usr/bin/env python 

for i in xrange(1000): 
    print "Hello, World!"
Finally, here are the error messages:

Error:
C:\Users\Michael\Desktop\helloworld>python c:\pyInstaller-3.2\Makespec.py --onefile --console --upx --tk helloworld.py usage: Makespec.py [-h] [-D] [-F] [--specpath DIR] [-n NAME] [-p DIR]                    [--hidden-import MODULENAME]                    [--additional-hooks-dir HOOKSPATH]                    [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]                    [--key KEY] [-d] [-s] [--noupx] [-c] [-w]                    [-i <FILE.ico or FILE.exe,ID or FILE.icns>]                    [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]                    [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]                    [--win-no-prefer-redirects]                    [--osx-bundle-identifier BUNDLE_IDENTIFIER]                    [--log-level LEVEL] [--upx UPX]                    scriptname [scriptname ...] Makespec.py: error: argument --upx/-X/-K/--tk/-C/--configfile/--skip-configure/-o/--out/--buildpath: expected one argument C:\Users\Michael\Desktop\helloworld>python c:\pyInstaller-3.2\PyInstaller\building\build_main.py helloworld.spec Traceback (most recent call last):   File "c:\pyInstaller-3.2\PyInstaller\building\build_main.py", line 27, in <module>     from .. import HOMEPATH, DEFAULT_DISTPATH, DEFAULT_WORKPATH ValueError: Attempted relative import in non-package C:\Users\Michael\Desktop\helloworld>pause Press any key to continue . . .
Reply
#2
Simply install pyinstaller using pip
Then open a command promt, change the directory to the location of the .py file
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>cd /d c:\users\michael\desktop\helloworld\
then execute pyinstaller using
c:\users\michael\desktop\helloworld>pyinstaller --onefile --console --upx --tk helloworld.py
For certain uses you may edit the contents of myscript.spec (described under Using Spec Files). After you do this, you name the spec file to PyInstaller instead of the script:
c:\users\michael\desktop\helloworld>pyinstaller helloworld.spec
Reply
#3
I got stuck on the second step.

here is the activity and error
c:\Users\Michael\Desktop\helloworld>dir
Volume in drive C is OS
Volume Serial Number is A2D2-EFB5

Directory of c:\Users\Michael\Desktop\helloworld

12/08/2016  05:06 PM    <DIR>          .
12/08/2016  05:06 PM    <DIR>          ..
12/08/2016  03:20 PM               169 helloworld.bat
12/08/2016  02:43 PM                76 helloworld.py
12/08/2016  05:06 PM                 0 pyinstaller
              3 File(s)            245 bytes
              2 Dir(s)  709,115,584,512 bytes free

c:\Users\Michael\Desktop\helloworld>pyinstaller --onefile --console --upx --tk helloworld.py
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME] [-p DIR]
                  [--hidden-import MODULENAME]
                  [--additional-hooks-dir HOOKSPATH]
                  [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
                  [--key KEY] [-d] [-s] [--noupx] [-c] [-w]
                  [-i <FILE.ico or FILE.exe,ID or FILE.icns>]
                  [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE]
                  [--uac-admin] [--uac-uiaccess] [--win-private-assemblies]
                  [--win-no-prefer-redirects]
                  [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                  [--distpath DIR] [--workpath WORKPATH] [-y]
                  [--upx-dir UPX_DIR] [-a] [--clean] [--log-level LEVEL]
                  [--upx UPX]
                  scriptname [scriptname ...]
Error:
pyinstaller: error: argument --upx/-X/-K/--tk/-C/--configfile/--skip-configure/-o/--out/--buildpath: expected one argument c:\Users\Michael\Desktop\helloworld>
Reply
#4
Try executing with no options to begin with to see if it works like that
c:\users\michael\desktop\helloworld>pyinstaller helloworld.py
pyinstaller options
--upx-dir UPX_DIR requires a path to UPX utility (default: search the execution path)
is --tk a valid option I didn't spot it.
Reply
#5
Yes, that ran okay and the the exe file was found in the dist/helloworld folder

and it ran so there must be something in the previous options that caused the error

one more question, at the end oif the original command there was a --tk

is tk supposed to be an executable somewhere?

Anyway, thanks for the help
Reply
#6
Read the rest of my previous post Tongue
Reply
#7
Oh yea, I see it now.

--tk came from a "simple" install document that got me to this point.

the path to UPX in set up on this system but removing --tk didn't help.

I removed the --upx and --tk and it worked.

Again, thanks for the help.
Reply
#8
The manual is here, in case all else fails: https://pythonhosted.org/PyInstaller/
Reply
#9
Thanks Larz60+
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trouble with installing python domingo251 2 562 Sep-23-2023, 12:03 AM
Last Post: ICanIBB
  Pyinstaller 3 Python 2 mckymntl 0 1,206 Feb-07-2022, 06:28 AM
Last Post: mckymntl
  making variables in my columns and rows in python kronhamilton 2 1,576 Oct-31-2021, 10:38 AM
Last Post: snippsat
  Python 3.7, Windows 10, pyinstaller, winsound, no sound in executable kmarien 3 3,587 Nov-30-2020, 04:10 PM
Last Post: buran
  New to python, having trouble with an exercise Salkay 3 2,101 Feb-18-2020, 01:42 AM
Last Post: Salkay
  Cannot Change Python script to exe using Pyinstaller omar_mohsen 3 2,335 Dec-19-2019, 01:05 PM
Last Post: buran
  More Python Embedding Trouble jibarra 3 2,871 Jul-11-2019, 09:25 PM
Last Post: Gribouillis
  Making a generalised CSV COPY script in Python Sandy7771989 3 2,379 Jul-05-2019, 11:02 PM
Last Post: Larz60+
  Error with using pyinstaller to convert python script in Mac OS Takeshio 2 5,319 Oct-19-2018, 02:42 PM
Last Post: Takeshio
  Trouble making an argument optional linuxnoob 2 2,865 Aug-31-2018, 01:52 AM
Last Post: linuxnoob

Forum Jump:

User Panel Messages

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