首页 > 解决方案 > Python 错误出现在 Rust Cargo 中

问题描述

当我出于某种原因尝试使用 Cargo 运行库示例时,会出现 Python 错误。我不知道为什么或如何发生这种情况,有人认为他们可能知道如何解决这个问题吗?

cargo run --example lib_example
module 'json' has no attribute 'JSONDecodeError'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 117, in get_snaps
    snaps = json.loads(output)
AttributeError: module 'json' has no attribute 'loads'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 23, in crash_guard
    callback()
  File "/usr/lib/command-not-found", line 95, in main
    if not cnf.advise(args[0], options.ignore_installed) and not options.no_failure_msg:
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 364, in advise
    snaps, mispell_snaps = self.get_snaps(command)
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 118, in get_snaps
    except json.JSONDecodeError as e:
AttributeError: module 'json' has no attribute 'JSONDecodeError'

标签: pythonrust-cargo

解决方案


我不知道为什么,但which为了货物而跑然后重新启动以某种方式修复它。

which cargo
sudo reboot

推荐阅读