I'm very new to python and especially to its ecosystem. Today, I was trying to invoke a python command from my command line that worked perfectly yesterday, but today I got the following fatal error:
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
ModuleNotFoundError: No module named 'site'
Current thread 0x00000cac (most recent call first):
<no Python frame>
While trying to find the problem, I soon realized that it was not special to my command. In fact, all python-related executables produce the same error when invoked from any command prompt, no matter where I am in my filesystem. python
, python3
, anaconda
(and its prompt), conda
, pip
, pip3
, ... All of these suddenly don't work anymore. They all fail with the same error message, only the thread is altering.
In my research I found a very similar error very often, but it was about the encodings
module. Also I haven't read about issues where the entire python ecosystem just broke.
Solutions to said similar error seem to include doing something with the PYTHONPATH
and PYTHONHOME
envs if they exist. But I don't have them, neither as user variable nor as system var.
I installed python by installing anaconda3 via scoop. It should be the latest version (2020.11). I've been using the installation inside of PyCharm
as well as via the command line.
Does anyone know what the problem here could be? I'm kinda stuck here because I can't even use conda or pip for diagnostics, like calling conda list
to find out more about the site
packages' status. So, if anyone could help me with this, I'd be very thankful!
I had this error.
For me, I had some project tree (fictitious):
doc/
├── project/
│ ├── embedded/
| | ├── __init__.py
│ │ ├── deep_file
│ │ └── utils/
│ │ └── os.py # < This one! Look here!!
│ │ └── deep/
│ │ └── folder/
│ │ └── very_deep_file
│ └── less_deep_file
|...
Within this tree, I had a file named .../utils/os.py
.
Pycharm debug mode would find this os.py
and use it in place of the default os.py
. To solve this problem, I renamed os.py
to something else.
What a dummy I am! Hopefully this saves other people time and headache!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With