One day when messing with Python in PyCharm, I encountered a quite silly problem. Namely, when I try to run a simple script in a file named abc.py
, I receive an error. I tried to run the same file directly from the terminal and it looks fine.
abc.py
print("Hello world")
Output:
/Users/.../venv/bin/python /Users/.../abc.py
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/io.py", line 52, in <module>
File "/Users/.../abc.py", line 1, in <module>
RuntimeError: lost sys.stdout
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
Just out of curiosity, what is the matter here?
EDIT: Why does it happen only when running from PyCharm, and not when from the terminal?
abc
is standard module of python. Here => https://docs.python.org/3/library/abc.html
It should works if you rename your own module abc.py in something else like abcd.py
You get an error because python is confused.
You see, there is a built in module in python, that is also called abc(short for 'Abstract Base Classes')!
I suggest you name your file something else, or the other crazy way,delete the module (just kidding, don't do that!).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With