I'm unable to create the .exe for the most simple 'hello world' example

Viewed 856

I've used py2exe successfully for previous projects on previous build machines, but now I've freshly installed everything from scratch and can't run the simplest example:

setup.py:

from distutils.core import setup
import py2exe
  
setup(console=['hello.py'])

hello.py:

print("Hello World") 

Command: python3 setup.py py2exe Output:

running py2exe

  1 missing Modules
  ------------------
? _posixshmem                         imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
Building 'dist\hello.exe'.
error: [WinError 87] The parameter is incorrect.

dest\hello.exe is generated (37 kB!) but gives the following error when run:

Could not locate script resource:The specified resource type cannot be found in the image file.
FATAL ERROR: Could not locate script

The versions I have installed are:

python --version
Python 3.8.6

pip freeze
cachetools==4.1.1
future==0.18.2
numpy==1.19.3
opencv-python==4.4.0.46
pefile==2019.4.18
py2exe==0.10.1.0
pyreadline==2.1
pywin32==300

systeminfo
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19041 N/A Build 19041
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Hotfix(s):                 6 Hotfix(s) Installed.
                           [01]: KB4580419
                           [02]: KB4561600
                           [03]: KB4577266
                           [04]: KB4580325
                           [05]: KB4586864
                           [06]: KB4586781
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.

I know that there is clearly something weird happening (I've already hit the issue with 'numpy' here: https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html ) ... but I can't quite see what it is.

Thanks !

-- Mac

1 Answers

You just misstyped the command line flag, should be: python setup.py py2exe.
Works fine for me on Win7, Python 3.8.0:

(py38) λ python setup.py py2exe
running py2exe

  2 missing Modules
  ------------------
? _posixshmem                         imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
? readline                            imported from cmd, code, pdb
Building 'dist\hello.exe'.
Building shared code archive 'dist\library.zip'.
Copy c:\users\f3k\envs\py38\scripts\python38.dll to dist
...
Copy DLL C:\Python38\DLLs\libffi-7.dll to dist\

C:\temp
(py38) λ dist\hello.exe
Hello World
Related