0%

Repo 报错 No module named 'formatter'

报错日志:

Traceback (most recent call last):
  File "/home/liux/projects/android_lineage/.repo/repo/main.py", line 56, in <module>
    from subcmds.version import Version
  File "/home/liux/projects/android_lineage/.repo/repo/subcmds/__init__.py", line 35, in <module>
    mod = __import__(__name__,
          ^^^^^^^^^^^^^^^^^^^^
  File "/home/liux/projects/android_lineage/.repo/repo/subcmds/help.py", line 20, in <module>
    from formatter import AbstractFormatter, DumbWriter
ModuleNotFoundError: No module named 'formatter'

报错原因:

Python 3.10 开始移除了 formatter 这个模块.

https://docs.python.org/3.10/whatsnew/3.10.html#removed

补救措施

下载旧版本提取模块文件.

wget https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz
tar zxvf Python-3.9.18.tgz
sudo chmod 644 Python-3.9.18/Lib/formatter.py
sudo chown root:root Python-3.9.18/Lib/formatter.py
sudo cp Python-3.9.18/Lib/formatter.py /usr/lib/python3.11/formatter.py

注意 python 的目标路径, 不同版本有不同;

  • 本文作者: 6x
  • 本文链接: https://6xyun.cn/article/191
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-ND 许可协议。转载请注明出处!