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

后端 未结 2 1483
别跟我提以往
别跟我提以往 2021-01-18 06:04

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

Fatal Python er         


        
2条回答
  •  情深已故
    2021-01-18 06:52

    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.

提交回复
热议问题