在ubuntu16.04中输入不存在shell命令时,报错ModuleNotFoundError的解决方案

背景:在拿到ubuntu机器后,我在系统上安装了python的3.7版本,在安装过程中删除了一个lsb_release.py文件,之后我的shell命令就使用异常了。

报错触发原因

当我输入ubuntu无法识别的命令的时候,正常来说应该提示类似于 command not found 之类的字眼,但是系统确报了如下错误:

报错详情:

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 27, in <module>
    from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'

解决方案:

sudo apt-get remove --purge python3*
sudo apt auto remove

参考链接:https://askubuntu.com/questions/766246/missing-package-commandnotfound

总结:在删除系统的东西前先思考一下,千万别手贱!!!

原文地址:https://www.cnblogs.com/finlu/p/11588870.html