15

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.

6
  • 4
    By any chance is your python file called io.py? bugs.python.org/issue21202 Commented Aug 21, 2018 at 14:41
  • Even when I just try to start IDLE this error shows up. Also don't have any file named io.py . Commented Aug 21, 2018 at 14:59
  • Are you running this on pycharm?? If so check this stackoverflow.com/questions/26569828/… Can you try from the command line python <whatever script>? Commented Aug 21, 2018 at 15:02
  • No I am using cmd in Windows 10. Also when I try python <any script>, same error shows up. Commented Aug 21, 2018 at 15:25
  • Can you type python on your terminal and open the interpreter (if not then it is.a python installation error, and I know nothing about windows) Commented Aug 21, 2018 at 15:28

6 Answers 6

16

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.

Sign up to request clarification or add additional context in comments.

1 Comment

removing the PYTHONPATH worked.
5

Experienced this myself with creating a file named "abc.py".

Renaming the file corrected the issue.

2 Comments

Same here, I created a folder named abc, and put a test.py in it.
abc is confict with python's abstract class module
4

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.

Comments

3

I had named a package "io" which caused this error. Renaming to something else fixed it.

Comments

0

This problem can be reproduced by running conda in the geopandas directory of the geopandas package, and is caused by a directory named io. If you run into this issue, try changing your working directory.

Comments

-1

just restarted computer and solved my problem!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.