没有名为'编码'的模块

时间:2017-11-08 01:55:36

标签: python

我的操作系统是Ubuntu 17.10。

我正在尝试运行(并开发)一个python项目,但是当我这样做时,我得到了:

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

Current thread 0x00007f8c459bf740 (most recent call first):

我尝试过ImportError: No module named 'encodings'的建议,即:

  1. 我删除了旧的虚拟环境,
  2. 创建一个名为venv
  3. 的新帐户
  4. 运行source venv/bin/activate
  5. pip install -r requirements.txt
  6. 另外,在pycharm中,我已经去了File>设置>项目> Project Interrupter - 并将其设置为使用相同的虚拟环境。

    我也试过sudo dpkg-reconfigure python3

    但我仍然得到同样的错误。

2 个答案:

答案 0 :(得分:0)

我发现这条消息是在设置uwsgi时由“.ini”文件中指向虚拟环境的无效指针引起的。

答案 1 :(得分:0)

在更新到macOS Catalina之后,我遇到了类似的问题“ ModuleNotFoundError:没有名为'encodings'的模块。

我的系统中安装了多个版本的Python。

从macOS系统中删除所有python版本(2.7和3.7.4)并重新安装最新的python 3.8对我来说很有效。

要从macOS中删除python,我已按照此处的说明How to uninstall Python 2.7 on a Mac OS X 10.6.4?

相关问题