Python Forum

Full Version: Trouble making my first python .exe using pyinstaller.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 . . .
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
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>
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.
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
Read the rest of my previous post Tongue
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.
The manual is here, in case all else fails: https://pythonhosted.org/PyInstaller/
Thanks Larz60+