Magick
Magick

Reputation: 5112

No module named 'encodings'

My operating system is Ubuntu 17.10.

I have am trying to run (and develop) a python project, but when I do I get:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f8c459bf740 (most recent call first):

I have tried advice from ImportError: No module named 'encodings', namely:

  1. I have removed old virtual environment,
  2. create a new one, named venv
  3. run source venv/bin/activate
  4. pip install -r requirements.txt

Also, in pycharm, I have gone File > Settings > Project > Project Interrupter - and set this to use the same virtual environment.

I have also tried sudo dpkg-reconfigure python3

But I still get the same error.

Upvotes: 1

Views: 14100

Answers (2)

Kondal Kolipaka
Kondal Kolipaka

Reputation: 3549

I was facing a similar issue "ModuleNotFoundError: No module named 'encodings" after updating to macOS Catalina.

I was having multiple versions of Python installed in my system.

Removing all the python versions(2.7 and 3.7.4) from macOS system and reinstalling the latest python 3.8 worked for me.

To remove a python from macOS, I've followed the instructions from here How to uninstall Python 2.7 on a Mac OS X 10.6.4?

Upvotes: 0

steven_ganz
steven_ganz

Reputation: 33

I've found this message to be caused, on setting up uwsgi, by an invalid pointer to the virtual environment in the ".ini" file.

Upvotes: 1

Related Questions