Search code examples
pythonanaconda3

Fatal Python error: init_import_size: Failed to import the site module in Anaconda Prompt


When I launch Anaconda Prompt I get the following error message:

Fatal Python error: init_import_size: Failed to import the site module Python runtime state: initialized
Traceback (most recent call last):
File "C:\Users\blue-\AppData\Local\Programs\Python\Python39\Lib\site.py", line 73, in
import os
File "C:\Users\blue-\AppData\Local\Programs\Python\Python39\Lib\os.py", line 29, in
from _collections_abc import _check_methods
File "C:\Users\blue-\AppData\Local\Programs\Python\Python39\Lib_collections_abc.py", line 12, in
GenericAlias = type(list[int])
TypeError: 'type' object is not subscriptable

This question was asked previously here, but it wasn't answered so I'm trying my luck by asking it again.

Sidenote: I don't know if this is relevant information, but I also can't open the Anaconda Navigator or any Anaconda apps.


Solution

  • Are you running another python3 set up in your machine ? Because this error occurs when more than one python environment is there. The best solution is to uninstall other python versions set up and do clean installation. Other solutions will be. a) Check your .bashrc file (if using Ubuntu) and remove the PATH variables to other python versions and only keep the PATH variable for Anaconda.

    b) Run the python scripts specific python binary.

    /home/username/Programs/anaconda3/bin/python3 file.py
    

    I hope, these solutions will work