3

I use Ubuntu, Python 3.4 and try to compile my py scripts to exe using py2exe.

Unfortunately When I try to use command 'build_exe', it generates error! Could anybody help me to solve it or advise how to compile py project to exe in another way?

Error code:

NameError: name 'WinDLL' is not define.

enter image description here

Wajahat
  • 1,593
  • 3
  • 20
  • 47
ngtest
  • 61
  • 1
  • 1
  • 3

2 Answers2

6

py2exe is for windows...

On linux you can try PyInstaller:
http://www.pyinstaller.org/

PyInstaller is now able to build Windows executables when running under Linux. See documentation for more details.

CodeNinja
  • 1,168
  • 2
  • 14
  • 27
  • PyInstaller Unfortunately does not support Python 3.4 – ngtest Sep 18 '14 at 13:46
  • @CodeNinja, maybe i didn't get it but the tool's FAQ says that you can't package windows binaries while running under linux. https://github.com/pyinstaller/pyinstaller/wiki/FAQ the cross compiling you pointed out is a dead link now... http://www.pyinstaller.org/browser/tags/1.4/doc/CHANGES.txt – chaiyachaiya Dec 18 '14 at 11:32
0

The py2exe module needs to be run from within a command prompt shell (aka Windows terminal) to make a Windows executable, since just like pyinstaller, "they use the OS support to load the dynamic libraries, thus ensuring full compatibility". That's why you get the ''WinDLL' is not defined' error when using the py2exe module in a bash shell.

py2exe works until python-3.4 and pyinstaller works until python-3.7. The latest version at time of writing is 3.8. Use the python module virtualenv from command prompt to get the adeqaute python version running (without replacing your current python set-up), and make your executable file. Here is my answer with code. --> Make sure to add python to your Windows path on install, so you can use the pip and python commands in command prompt. Otherwise you have to replace these commands in my answer for their fullpath, e.g. C:\Users\jakethefinn\python37\pip.exe and C:\Users\jakethefinn\python37\python.exe respectively. If you install python from Microsoft Store, the files pip.exe and python.exe are automatically added to path.