Forums

Fatal Python error: Py_Initialize: Unable to get the locale encoding

I deployed my existing django project. When I access the site I get this error:

Something went wrong :-( This website is hosted by PythonAnywhere, an online hosting environment. Something went wrong while trying to load it; please try again later.

Debugging tips If this is your PythonAnywhere-hosted site, and you just reloaded it, then the problem might simply be that it hasn't loaded up yet. Try refreshing this page and see if this message disappears.

If you keep getting this message, you should check your site's server and error logs for any messages — you can view them from the Web tab inside PythonAnywhere.

If there's nothing in the logs, and you're sure your site is OK, then it might be a problem on our side. Drop us a line at support@pythonanywhere.com, in the forums, or using the "Send feedback" link on the site, quoting the error code below.

Error code: 502-backend

The server log gives me this error:

2018-08-25 19:33:07 Fatal Python error: Py_Initialize: Unable to get the locale encoding 2018-08-25 19:33:07 ModuleNotFoundError 2018-08-25 19:33:07 : 2018-08-25 19:33:07 No module named 'encodings'

Anybody knows what that could be?

Ok. I resolved it. I installed the wrong Python version with my virtualenv (it didn't work with 2.7 but when I created a new env. with Python Version 3.6 it worked)

            / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\   
<<<<<<:>~  <   Yay!         |  
            \_________/