14

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.

Fatal Python Error
  • 205
  • 1
  • 3
  • 6
  • 4
    By any chance is your python file called io.py? https://bugs.python.org/issue21202 – E.Serra Aug 21 '18 at 14:41
  • Even when I just try to start IDLE this error shows up. Also don't have any file named io.py . – Fatal Python Error Aug 21 '18 at 14:59
  • Are you running this on pycharm?? If so check this https://stackoverflow.com/questions/26569828/pycharm-py-initialize-cant-initialize-sys-standard-streams Can you try from the command line python ? – E.Serra Aug 21 '18 at 15:02
  • No I am using cmd in Windows 10. Also when I try python , same error shows up. – Fatal Python Error Aug 21 '18 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) – E.Serra Aug 21 '18 at 15:28
  • No unfortunately. Can't even open interpreter. While it could be installation error, python was working fine until yesterday don't understand what is causing this now. – Fatal Python Error Aug 21 '18 at 15:36

6 Answers6

15

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.

Biarys
  • 1,065
  • 1
  • 10
  • 22
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.

4

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

Renaming the file corrected the issue.

Rider91
  • 41
  • 2
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.

kilojoules
  • 9,768
  • 18
  • 77
  • 149
0

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

Thomas
  • 8,306
  • 8
  • 53
  • 92
-1

just restarted computer and solved my problem!

Princekin
  • 696
  • 9
  • 18