Python 3.8 crashes when trying to redirect STDOUT to a file

Questions about Wine on Linux
Locked
dvniekerk
Newbie
Newbie
Posts: 1
Joined: Fri Jun 05, 2020 10:18 am

Python 3.8 crashes when trying to redirect STDOUT to a file

Post by dvniekerk »

Good day,

Python 3.x installed via the standard installers from python.org seems to run well under Wine. However, I am finding that the Python interpreter crashes when I try to redirect STDOUT to a file. Starting without a Wine Prefix in Ubuntu 20.04 I install Python 3.8.3 https://www.python.org/ftp/python/3.8.3 ... -amd64.exe as follows:

Code: Select all

$ wine python-3.8.3-amd64.exe /quiet Include_doc=0 Include_dev=0 Include_test=0 PrependPath=1
and I can then do the following successfully:

Code: Select all

$ wine python -c 'print("hello world")'
but when I redirect the output to a file it crashes:

Code: Select all

$ wine python -c 'print("hello world")' > out.txt
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
OSError: [WinError 6] Invalid handle

Current thread 0x0000002b (most recent call first):
<no Python frame>
I have not yet tried to do this with a later version of Wine (I am using

Code: Select all

wine-5.0 (Ubuntu 5.0-3ubuntu1)
) because this is likely just a misconfiguration issue involving console encodings or environment or am I mistaken?

Doing the above with Python 3.4.4 https://www.python.org/ftp/python/3.4.4 ... .amd64.msi installed as follows:

Code: Select all

$ wine msiexec /i python-3.4.4.amd64.msi
works as expected, it creates a text file out.txt containing "hello world".

Please let me now if I've neglected to include important information or should rather be following this up with the Python developers.

Thank you and kind regards,
Daniel van Niekerk
melund
Newbie
Newbie
Posts: 1
Joined: Wed Sep 29, 2021 2:50 am

Re: Python 3.8 crashes when trying to redirect STDOUT to a file

Post by melund »

I have stumbled on this problem as well. Also happens with python 3.7. Did you find a any workaround for this?
invisible kid
Level 5
Level 5
Posts: 354
Joined: Tue Dec 24, 2019 3:23 pm

Re: Python 3.8 crashes when trying to redirect STDOUT to a file

Post by invisible kid »

I couldn't easily get a windows python executable to test with, but could it be the redirection symbol is being applied to the windows environment and not to the linux environment? I vaguely remember going through the docs to get the correct syntax.

Something that would be similar to: "wine python -c 'print("hello world")'" > out.txt (added "s around wine command)
I don't think that works, but describes the intent.
Locked