Fatal Python error when running file (in debug mode the same)

Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
  File "/home/oleg/Python_Lessons/venv/lib/python3.7/site.py", line 703, in <module>
    main()
  File "/home/oleg/Python_Lessons/venv/lib/python3.7/site.py", line 683, in main
    paths_in_sys = addsitepackages(paths_in_sys)
  File "/home/oleg/Python_Lessons/venv/lib/python3.7/site.py", line 281, in addsitepackages
    if os.path.isdir(sitedir):
  File "/home/oleg/Python_Lessons/venv/lib/python3.7/genericpath.py", line 45, in isdir
    return stat.S_ISDIR(st.st_mode)
AttributeError: module 'stat' has no attribute 'S_ISDIR'

I get this error when I try Run or Debug any file. In PyCharm 2018 or PyCharm 2019, with python3.6 or python3.7 I get the same error . OS - Linux Mint 19

How I can resolve this problem? Thanks!

 

 

0
3 comments

Make sure you don't have object in your code which shadows the build-in `stat` module: https://docs.python.org/2/library/stat.html

Try running your code from the terminal outside of IDE.

1

Hi Andrey! Thank you for your reply.

You are right! Yesterday I found the source of the problem, it was a stat.py file in the root folder of my project. The name of this file coincided with the name of the file that Pycharm calls during operation, which caused this problem.

This problem is resolved! Thanks!

0

I have a package named io;  This also seems to cause the same problem

Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
AttributeError: module 'io' has no attribute 'open'

0

Please sign in to leave a comment.