尝试在 Ubuntu 22.04 上启动 bpython 时出现以下错误

尝试在 Ubuntu 22.04 上启动 bpython 时出现以下错误

当我尝试在 Ubuntu 22.04 上启动 bpython 时,出现以下错误。直到最近,它一直运行正常,但在我使用 pip 更新一些模块后,出现了这种情况。我们该如何解决这个问题?

Traceback (most recent call last):
  File "/usr/bin/bpython", line 33, in <module>
    sys.exit(load_entry_point('bpython==0.22.1', 'console_scripts', 'bpython')())
  File "/usr/bin/bpython", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 16, in <module>
    from . import args as bpargs, translations, inspection
  File "/usr/lib/python3/dist-packages/bpython/args.py", line 42, in <module>
    import requests
  File "/usr/lib/python3/dist-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 29, in <module>
    from .connection import (
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/connection.py", line 39, in <module>
    from .util.ssl_ import (
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/util/__init__.py", line 3, in <module>
    from .connection import is_connection_dropped
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/util/connection.py", line 3, in <module>
    from .wait import wait_for_read
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/util/wait.py", line 1, in <module>
    from .selectors import (
  File "/home/cuser/.local/lib/python3.10/site-packages/urllib3/util/selectors.py", line 14, in <module>
    from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

答案1

你有一个旧版本的 urllib3/home/cuser/.local/lib/python3.10/site-packages/urllib3/ 它不适用于 Python 3.10 及更高版本,并且会覆盖新版本。

只需删除,这样就可以找到/home/cuser/.local/lib/python3.10/site-packages/urllib3/已作为依赖项安装的较新的版本。apt

相关内容