New submission from Patrick Rutkowski:

Install Visual Studio 2017

Download and unpack Python-3.6.2.tgz

Open a Visual Studio command prompt
Browse to Python-3.6.2\PCBuild
Run build.bat -p x64 -c Release
Run build.bat -p x64 -c Debug
Add the PCbuild\amd64 directory to your PATH

Create a new Visual Studio Win32 GUI project called mypythonw

Copy-paste the source code of Python-3.6.2\PCBuild\WinMain.c into your mypthonw 

Add Python-3.6.2\Include and Python-3.6.2\PC to mypythonw's include path.

Add Python-3.6.2\PCbuild\amd64 to mypythonw's library search path

Build mypthonw

Run these two commands:

pythonw -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello World!', 
'Hello', 0)

mypythonw -c "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Hello 
World!', 'Hello', 0)

The first will show a message box, while the second will show nothing. You 
won't get an error message or a debugger from mypythonw.exe. It'll just 
silently do nothing.

There must be something in the configuration of pythonw.vcxproj that is 
necessary for Python embedding to work, and which makes it work in pythonw but 
fail in mypythonw. The two projects are executing the exact same C code, but 
one works and the other doesn't. What's going on here?

messages: 300055
nosy: rutski
priority: normal
severity: normal
status: open
title: Py_Main() is totally broken on Visual Studio 2017

Python tracker <>
Python-bugs-list mailing list

Reply via email to