40

I'm trying to use PyCharm IDE but none of my programs compile even simple Hello World. PyCharm gives this error:

Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "C:\Python34\lib\io.py", line 72, in <module>
AttributeError: 'module' object has no attribute 'ABCMeta'
Process finished with exit code 3

I'm not able to find the solution for it and also referred the link PyDev: Fatal error Python32\lib\io.py, line 60, in <module> but there is no solution there.

Python 3.4 is installed on my Win 7 OS system.

4
  • 26
    Change your file's name from io.py to something else. Commented Oct 26, 2014 at 5:36
  • 7
    I solved my issue. Apparently PyCharm is not able to execute a file named abc.py because there is an in-built module called abc in Python. Executing abc.py via command line works. Check if your file is named abc.py, if it is, rename it to something else. Commented Oct 26, 2014 at 10:27
  • @BurhanKhalid can you explain more about why is that the issue and how to avoid it? I cannot find list of "reserved filenames" or anything similar. Commented Oct 29, 2019 at 3:50
  • 3
    I had a similar problem. Earlier I had named my package 'io' Commented Dec 28, 2019 at 13:19

7 Answers 7

85

I faced the same problem because I created a file named abc.py, remove that file in your project, your error will disappear.

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

5 Comments

why the file name abc.py is not supported in pycharm?
If you name your file abc.py you're shadowing the standard library's abc (abstract base class). When you do that, everything that depends on the built-in abc will get yours instead. Unless you've essentially rewritten the standard library's code, things will break.
Echoing @david-c, changing the name of the module may work, but it should not be necessary. Unchecking a few boxes in "Run/Debug" configurations is a better solution.
it worked fine for me..
Apparently same issue occurred while using PyInstaller and this answer saved me
19

Yes, as you said in the comment, the problem is in the filename 'abc'. You will be able to run this file within PyCharm, if you uncheck:

  • Add content roots to PYTHONPATH
  • Add sources roots to PYTHONPATH

in the menu "Run/Debug Configurations".

5 Comments

This is what worked for me. I suspect it should be the accepted answer. There should be no magic-forbidden module names such as "abc.py".
Also worth checking to make sure the 'working directory' option isn't pointing to your file or subpackage.
In my case it was because the content root was a package installed to my local environment with pip install -e ..
It did not help me. Funny, that in my case it is only in Debug that I get this error.
I lost a whole afternoon to this, so thank you for posting this answer
15

I have the same problem, just change your file's name from io.py to something else, It's work!

2 Comments

This is just plain odd. I had to rename one of my packages its name was io and when debugging(and only then) would it not work! Afer changing to inout all worked.
LOL, i named a module 'io' as well
8

Finally found how to solve this problem in PyCharm: never use a name like abc.py or test.py.

Simply use another name, like a.py or my-unique-file-name.py

1 Comment

this is strange. The python-stdlib is very large and python is supposed to be beginner-friendly, so the average programmer is not expected to know their module name clashes with the stdlib.
3

try this: File->Setting->Editor->File Encodings change the Project encoding to UTF-8

Comments

1

In my case from .my_file import * caused the error. Changing it to from .my_file import func_1, func_2, func_3 solved it.

Comments

0

I was working on PyCharm, and I created a file named "abc.py" and started facing the same issue thus then I changed the name of "abc.py" to "anyuniquename.py" and the error disappeared.

Comments