38

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.

Georgy
  • 12,464
  • 7
  • 65
  • 73
  • 25
    Change your file's name from `io.py` to something else. – Burhan Khalid Oct 26 '14 at 05:36
  • 5
    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. – iridescent Oct 26 '14 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. – Hedrack Oct 29 '19 at 03:50
  • 3
    I had a similar problem. Earlier I had named my package 'io' – lab bhattacharjee Dec 28 '19 at 13:19

6 Answers6

83

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

Marcs
  • 3,768
  • 5
  • 33
  • 42
vinay
  • 831
  • 6
  • 2
  • why the file name abc.py is not supported in pycharm? – HarshitMadhav Mar 16 '18 at 19:27
  • 12
    If you name your file abc.py you're shadowing the [standard library's abc (abstract base class)](https://docs.python.org/3/library/abc.html). 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. – Ernst Jun 28 '18 at 09:57
  • 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. – Keith Ma Mar 28 '20 at 16:08
  • it worked fine for me.. – Mugeesh Husain Jan 12 '22 at 08:52
  • Apparently same issue occurred while using PyInstaller and this answer saved me – Samudra Ganguly Mar 05 '23 at 07:45
16

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".

15

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

janeluck
  • 151
  • 1
  • 4
  • 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. – MatBos Jul 24 '18 at 20:09
  • LOL, i named a module 'io' as well – havryliuk Jul 19 '22 at 14:58
7

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

Deqing
  • 14,098
  • 15
  • 84
  • 131
  • 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. – julaine Jun 19 '23 at 12:49
2

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

張家豪
  • 21
  • 3
0

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.

mmichal10
  • 322
  • 2
  • 13