-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import twstock
causes the script.pyw not run.
#128
Comments
It works on my Linux. Please run it in your terminal and see the error message from it. |
I suspect either you have multiple Python in your environment and the default one is not the one you installed twstock, or the tk init has some problem. |
script.pyw should be Windows exclusive? Correct me if I am wrong. PYW is run by pythonw.exe so that we could get rid of the black command window. I found the discussion here, but nothing works for me so far: https://stackoverflow.com/questions/24835155/pyw-and-pythonw-does-not-run-under-windows-7 My other PYW works fine and, Simply try twstock_not_run.pyw on Windows, it works without the |
That doesn't matter between platform.
As I said in the last reply, we should first figure out if there is any error message causing Python to exit early, and I suspect there has some problem of the enviroment or tk. In order to figure that out, we need to get the terminal first, so that we can get the error message.
Because pythonw does not show the terminal, thus you can see any error message.
You can try to open up a terminal: https://learn.microsoft.com/en-us/windows/terminal/faq And then run |
Let me rephrase the issue, it is Windows specific, pythonw.exe specific. You need to run
Since the pythonw.exe doesn't have the std output, cli module raises the exception. I reassign the # XXX: Repalce sys.stdout prevent Windows UnicodeEncodeError on cmd.exe
try:
stdout = io.TextIOWrapper(
getattr(sys.stdout, "buffer", sys.stdout), encoding="utf-8", errors="replace"
)
except AttributeError:
stdout = None |
Thank you, this is what we need to know in order to pin down the problem. Can you try the branch https://github.com/mlouielu/twstock/tree/fix-pythonw-128 for the fix? You can clone it and copy the "twstock/twstock" directory to the same as your pyw file, or download the zip file, unzip, and copy the "twstock/twstock" directory to the same as your pyw file. The directory of your pyw file should look like this:
Then Python should import the twstock with the fix. Please let me know the result, thanks! |
It looks fine. |
My PR didn't pass the unit test, I'll try to fix it later. |
Describe the bug
import twstock
causes the script.pyw not run.To Reproduce
Steps to reproduce the behavior:
Or you could use the script below "twstock_not_run.zip"
import twstock
in your script.import twstock
, then you could run the script by double-clicking.Expected behavior
Run!
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
twstock_not_run.zip
The text was updated successfully, but these errors were encountered: