PythonW does not run script. Seriously

  python

So, using Windows 10 and Python 3.6. I’ve created a .py script that runs fine in command prompt using the command python myscript.py, but when I make an exact copy of that script and give it the extension .pyw, and try to run it with pythonw with the command pythonw myscript.pyw, nothing happens. pythonw does not show up in my task manager at all, and part of this script sends feedback to my slack channel so I would know if it’s "running in the background" or not. I did see pythonw flash in my task manager for half a second before disappearing, so this tells me that the script is somehow crashing, but why would this be if it runs with python just fine? I want to run this script as a background process and not with the python command.

I’ve tried adding:

sys.stdout = open('log.txt', 'w')
sys.stderr = open('err.txt', 'w')

to the top of the .pyw script to force the outputs into those files. I’ve tried running the command pythonw myscript.py, still nothing, and have also tried just setting the pythonw.exe as the main program to open .pyw files, so I double click the script to run it, nothing starts. I know it runs in the background without a command prompt, that’s what I want, but the program itself isn’t running. I’ve check my environment variable paths as well which isn’t the issue as pythonw.exe is in the same folder as python.exe and python.exe runs from command prompt without issue.

What else can I try?

Source: Python Questions

LEAVE A COMMENT