好的,所以不知何故我在 macOS Mojave 下损坏了我的 python3 安装,我不确定如何。我多年来一直使用 macports 来保持 python 最新,但是当我现在安装 python38 时,我根本无法运行 python3。我总是得到这个:
$ python3.8
Fatal Python error: config_get_locale_encoding: failed to get the locale encoding: nl_langinfo(CODESET) failed
Python runtime state: preinitialized
$
Run Code Online (Sandbox Code Playgroud)
我卸载了 macports 版本并重新安装,同样的事情。卸载然后从 python.org 重新安装,同样的事情。
python27 运行良好。python37 也运行良好。如果我使用 python38 甚至无法工作,$python3.8 -I所以这不是一些站点包的奇怪之处。
这是真正奇怪的一点:虽然我无法从 shell(任何 shell,从 bash 尝试过)运行 python38,但我可以使用 IDLE.app 从 GUI 启动 python38。
奇怪的是,在我的另一台机器(我的笔记本电脑)上,用 macports 安装的 python38 工作得很好。
我很困惑,我不会轻易感到困惑。有任何想法吗?