本文链接:https://blog.csdn.net/ai_liuliu/article/details/95504095
安装meld
sudo apt-get install meld
启动meld
方法1、终端命令:meld&

方法2、搜索meld,如图

启动错误:
  File "/usr/bin/meld", line 73, in <module>
    import meld.conf
ModuleNotFoundError: No module named 'meld'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/meld", line 73, in <module>
    import meld.conf
ModuleNotFoundError: No module named 'meld'

经过几番查找,最后发现是Python版本问题,meld需要Python2的环境。因为之前研究Python,把Python的版本升级到了3.6.8,最终导致meld不能正常使用。
解决:
发现问题,就要解决问题。

1.

Switch back to Python2. You might not want to do this, as there probably was a reason for switching to Python3.
Switching back might result in other programs not working as expected.
See command update-alternatives for switching the default Python version.

去usr/bin 目录下面把python软链接改成python2的

2.

Force meld to use Python2. For doing so,
open /usr/bin/meld with root rights in a text editor and change the very first line
from: #!/usr/bin/python
to: #!/usr/bin/python2

去usr/bin 目录,把meld文件开头加上一个2,显示的用python2就OK

有以上两种方案,个人更倾向于第二种。虽然后续如果更新meld会比较麻烦,需要重新设置,但不会影响到系统本身的Python版本,也避免引起更多令人抓狂的问题。

修改后再次启动meld,大功靠成,接下来就可以进行代码对比了。如图:

总结有些简略,请大家多多包含。

感谢 https://blog.csdn.net/yang332233/article/details/89084481

02-12 18:39