Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal Python error: init_sys_streams: can't initialize sys standard streams AttributeError: module 'io' has no attribute 'OpenWrapper'

Python 3 installation was working fine until yesterday. Then this happened today. Output from command prompt (Windows 10) when I type Python:

Fatal Python error: init_sys_streams: can't initialize sys standard streams
AttributeError: module 'io' has no attribute 'OpenWrapper'

Current thread 0x00001204 (most recent call first):

Googled and searched thoroughly for answers in previous questions nothing seems to be helping.

Just in case if relevant, used Python 3 with VS code before this.

Also tried uninstalling current Python(3.6.5) and reinstall latest Python(3.7.0) but error still persists. Any help would be appreciated.

like image 625
Fatal Python Error Avatar asked Aug 21 '18 14:08

Fatal Python Error


2 Answers

Adding this for people with the same issue. OP was able to find the answer here (his answer on another forum):

https://python-forum.io/Thread-Fatal-Python-error-init-sys-streams-can-t-initialize-sys-standard-streams-Attribute?page=3

Just in case if someone again faces this exact same issue I would clarify what was the problem and how it was solved.

Initially it seemed like known python bug which happens when a file is named io.py which causes conflict with standard module io, this was clearly not case here. Member @Gribouillis here pointed out to try executing python -E and it worked. Afterwards @metulburr again pointed out this behavior is not normal for fresh python installations. This clearly meant something was wrong with PYTHONPATH in environment variables.

What I did next was to remove all python paths from paths in environment variables(check @snippsat's screenshot for reference). Then uninstalled current python version. It is important to get rid of all paths to python installation before reinstalling because error occurred due to a invalid (likely due to change in installation directory) python path in paths. This completely solved the problem.

Also to reiterate what @gribouillis said it was probably bad idea to add PYTHONPATH to system in first place.

like image 55
Biarys Avatar answered Sep 21 '22 06:09

Biarys


This may be due to an invalid value of PYTHONPATH set in your system. Unset the value of this environment variable using the following command unset PYTHONPATH This should now fix the problem. If the problem still persists, then re-install Python. Your issue should be solved now.

like image 37
Ojasvi Agarwal Avatar answered Sep 20 '22 06:09

Ojasvi Agarwal