Python Forum
Fatal Python error: init_sys_streams: can't initialize sys standard streams Attribute
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fatal Python error: init_sys_streams: can't initialize sys standard streams Attribute
#11
Sounds like exactly this:
https://bugs.python.org/issue21202

Quote:Naming a file io.py in the root directory of a project causes the following error on 2.7:

AttributeError: 'module' object has no attribute 'BufferedIOBase'

Similar issues arise on 3.x., although the error message is a bit more useful:

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

At the very least we should ensure that the error message is a bit more straightforward and clear, as I imagine its not all that uncommon to cause this kind of conflict.
Reply
#12
@snippsat checked my python's installation path. It was already C:\Program Files (x86)\Python37-32. After verifying with installer again, it seems when I go for custom installation and select 'Install for all users' this path is selected instead of 'appdata' path which is for single user.
Still just to be sure, I again installed it your way into C:\Python37-32 but still the same error.
Also checked the 'Hidden items' and searched for 'io.py' in installed directory. There's no conflict here. For your reference contents of my 'io.py' located at 'C:\Python37-32\Lib' without module docstring.

# New I/O library conforming to PEP 3116.

__author__ = ("Guido van Rossum <[email protected]>, "
              "Mike Verdone <[email protected]>, "
              "Mark Russell <[email protected]>, "
              "Antoine Pitrou <[email protected]>, "
              "Amaury Forgeot d'Arc <[email protected]>, "
              "Benjamin Peterson <[email protected]>")

__all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",
           "BytesIO", "StringIO", "BufferedIOBase",
           "BufferedReader", "BufferedWriter", "BufferedRWPair",
           "BufferedRandom", "TextIOBase", "TextIOWrapper",
           "UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"]


import _io
import abc

from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
                 open, FileIO, BytesIO, StringIO, BufferedReader,
                 BufferedWriter, BufferedRWPair, BufferedRandom,
                 IncrementalNewlineDecoder, TextIOWrapper)

OpenWrapper = _io.open # for compatibility with _pyio

# Pretend this exception was created here.
UnsupportedOperation.__module__ = "io"

# for seek()
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2

# Declaring ABCs in C is tricky so we do it here.
# Method descriptions and default implementations are inherited from the C
# version however.
class IOBase(_io._IOBase, metaclass=abc.ABCMeta):
    __doc__ = _io._IOBase.__doc__

class RawIOBase(_io._RawIOBase, IOBase):
    __doc__ = _io._RawIOBase.__doc__

class BufferedIOBase(_io._BufferedIOBase, IOBase):
    __doc__ = _io._BufferedIOBase.__doc__

class TextIOBase(_io._TextIOBase, IOBase):
    __doc__ = _io._TextIOBase.__doc__

RawIOBase.register(FileIO)

for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom,
              BufferedRWPair):
    BufferedIOBase.register(klass)

for klass in (StringIO, TextIOWrapper):
    TextIOBase.register(klass)
del klass

try:
    from _io import _WindowsConsoleIO
except ImportError:
    pass
else:
    RawIOBase.register(_WindowsConsoleIO)

@Mekire came across that. I am 100% sure there's no other file named 'io.py' in my Lib. If there was indeed a conflict, an uninstall and then again install in different directory at least should have allowed me to run Python IDLE from Windows cmd. But error still persists even if I do a fresh install in different directories.

(Aug-22-2018, 12:37 PM)buran Wrote:
(Aug-22-2018, 12:48 AM)FatalPythonError Wrote: error initially did occur when I tried to run a script through VS terminal
what was the name and exact location of this script?
script was named results.py and was located in T: of my computer.
Reply
#13
Why don't you search for io in the whole filesystem?
Reply
#14
Navigate in cmd to root folder of installation the type python.
This to make sure that Path don't mess up stuff.
Eg:
C:\Windows\System32>cd\

C:\>cd python37
C:\Python37>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
C:\Python37>cd\

C:\>cd python36
# Just to make the error with 3.6
C:\Python36>python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ModuleNotFoundError: No module named 'io'

Current thread 0x00007010 (most recent call first):

C:\Python36>
Reply
#15
(Aug-22-2018, 06:18 AM)Gribouillis Wrote: Find all the files in the filesystem named io.py or io.pyc or io.pyo, io.pyd etc
Searched entire PC there's only one io.py file. All other files just contain io.py in them so they show up in search results too.

(Aug-22-2018, 02:10 PM)snippsat Wrote: Navigate in cmd to root folder of installation the type python.
This to make sure that Path don't mess up stuff.
Eg:
C:\Windows\System32>cd\

C:\>cd python37
C:\Python37>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
C:\Python37>cd\

C:\>cd python36
# Just to make the error with 3.6
C:\Python36>python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ModuleNotFoundError: No module named 'io'

Current thread 0x00007010 (most recent call first):

C:\Python36>

Error:
Microsoft Windows [Version 10.0.17134.228] (c) 2018 Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>c: C:\WINDOWS\system32>cd Python37-32 The system cannot find the path specified. C:\WINDOWS\system32>cd \ C:\>cd Python37-32 C:\Python37-32>python Fatal Python error: init_sys_streams: can't initialize sys standard streams AttributeError: module 'io' has no attribute 'OpenWrapper' Current thread 0x0000139c (most recent call first): C:\Python37-32>
Still same error.
Reply
#16
Do you happen to have a PYTHONPATH environment variable? Try python -E
Reply
#17
(Aug-22-2018, 02:41 PM)Gribouillis Wrote: Do you happen to have a PYTHONPATH environment variable? Try python -E
THANKS!! THANK YOU SO MUCH!! This worked. At least my core python works now.
I don't exactly understand the need to put -E but when I type python -E in terminal it takes me in IDLE.
There are some other questions I have if you would kindly help me.

1. Why is this '-E' thing being installed by default? Is there any way to remove it? I just want it like before i.e take me to IDLE when I type 'python' instead of 'python -E'. Only want to keep one consistent python version installed on system.

2. I need to use external libraries and pip is not working. Any ideas about this?

3. VS code still doesn't detects Python installed on computer and shows No python version found. Just for testing purposes, I downloaded PyCharm and it also fails to detect python installed on computer.

Again thank you so much.
Reply
#18
This is most likely a dead end, but i will ask. Have you created a .pth file at all on this system? This should not effect the standard lib io module if there was another io file elsewhere because 1) the .pth filepaths are search after the standard library ones, and 2) an uninstall should remove it from site-packages anyways. Unless you did something weird. But if you never did create a .pth file and have no idea what that is , then just ignore this post.
Recommended Tutorials:
Reply
#19
Quote:1. Why is this '-E' thing being installed by default? Is there any way to remove it? I just want it like before i.e take me to IDLE when I type 'python' instead of 'python -E'. Only want to keep one consistent python version installed on system.

the E argument does this
Quote: -E Ignore environment variables like PYTHONPATH and PYTHONHOME that
modify the behavior of the interpreter.
You shouldnt have to do that to run a fresh python isntall. Continuing without fixing this first will cause future headaches.
Recommended Tutorials:
Reply
#20
(Aug-22-2018, 03:02 PM)metulburr Wrote: This is most likely a dead end, but i will ask. Have you created a .pth file at all on this system? This should not effect the standard lib io module if there was another io file elsewhere because 1) the .pth filepaths are search after the standard library ones, and 2) an uninstall should remove it from site-packages anyways. Unless you did something weird. But if you never did create a .pth file and have no idea what that is , then just ignore this post.
No never did anything like that. I did have Anaconda and Spyder installed before(which I uninstalled) which had Python 3.6.5 and the single system wide version on Windows was 3.6.3. This is only thing I can think of which might have caused this breakdown. Never bothered with anything .pth related.

(Aug-22-2018, 03:05 PM)metulburr Wrote:
Quote:1. Why is this '-E' thing being installed by default? Is there any way to remove it? I just want it like before i.e take me to IDLE when I type 'python' instead of 'python -E'. Only want to keep one consistent python version installed on system.

the E argument does this
Quote: -E Ignore environment variables like PYTHONPATH and PYTHONHOME that
modify the behavior of the interpreter.
You shouldnt have to do that to run a fresh python isntall. Continuing without fixing this first will cause future headaches.

Does that mean my PYTHONPATH and PYTHONHOME are broken for some reason? Any idead how to fix that?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error: audioio has no attribute 'AudioOut' netwrok 3 693 Oct-22-2023, 05:53 PM
Last Post: netwrok
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,469 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  python standard way of importing library mg24 1 933 Nov-15-2022, 01:41 AM
Last Post: deanhystad
  Running Standard Scaler in Python 3 Led_Zeppelin 1 1,302 Sep-05-2022, 06:35 PM
Last Post: deanhystad
  Handling Python Fatal Error richajain1785 7 6,016 Oct-14-2021, 01:34 PM
Last Post: Tails86
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,322 Aug-17-2021, 05:24 PM
Last Post: Franky77
  2 ways to initialize a list with all zero quazirfan 2 1,838 Aug-06-2021, 03:27 PM
Last Post: deanhystad
  Attribute Error received not understood (Please Help) crocolicious 5 2,731 Jun-19-2021, 08:45 PM
Last Post: crocolicious
  error in scapy attribute 'haslayer' evilcode1 5 6,615 Mar-02-2021, 11:19 AM
Last Post: evilcode1
  Fatal error after trying to play sound. giladal 0 1,950 Oct-22-2020, 10:27 AM
Last Post: giladal

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020