OK, so somehow I have mangled my python3 installation under macOS Mojave and I'm not sure how. I've used macports for years to keep python up to date but when I installed python38 now I cannot run python3 at all. I always get this:
$ python3.8
Fatal Python error: config_get_locale_encoding: failed to get the locale encoding: nl_langinfo(CODESET) failed
Python runtime state: preinitialized
$
I uninstalled the macports version and reinstalled, same thing. Uninstalled and then installed fresh from python.org, same thing.
python27 runs fine. python37 also runs fine. python38 won't even work if I use $python3.8 -I
so it's not some site package weirdness.
Here's the really weird bit: while I cannot run python38 from a shell (any shell, tried from bash , I can launch python38 from the GUI using IDLE.app.
Oddly, on my other machine (my laptop), python38 installed with macports works just fine.
I'm flummoxed and I don't flummox easily. Any ideas?
Try setting LANG with a locale:
export LANG="en_US.UTF-8"
I had the same problem and fixed it by putting the following variable definition in my ~/.profile:
export LC_CTYPE="en_US.UTF-8"
LC_CTYPE was originally set to "De_DE" and was missing the encoding.
You should choose your language and country and set the value accordingly, e.g. this value for German/Germany:
export LC_CTYPE="de_DE.UTF-8"
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