我在 Ubuntu 24.04 上安装了 safeeyes,但它不起作用。
当我从命令行运行它时,出现以下错误。
$ safeeyes
Traceback (most recent call last):
File "/usr/bin/safeeyes", line 33, in <module>
sys.exit(load_entry_point('safeeyes==2.1.5', 'console_scripts', 'safeeyes')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/safeeyes", line 25, in importlib_load_entry_point
return next(matches).load()
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
module = import_module(match.group('module'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/safeeyes/__main__.py", line 32, in <module>
from safeeyes import utility
File "/usr/lib/python3/dist-packages/safeeyes/utility.py", line 24, in <module>
import imp
ModuleNotFoundError: No module named 'imp'
如何修复它?
Ubuntu 24.04 附带的 safeeyes 版本与 Ubuntu 24.04 的默认 python 版本 python3.12 不兼容。
要修复它,您可以手动应用上游的补丁。跑步
sudo nano /usr/lib/python3/dist-packages/safeeyes/utility.py
。注释掉(或删除)第 24 行,
import imp
然后,将第 357 行 (
imp.find_module(module)
) 替换为importlib.util.find_spec(module)
。现在安全眼应该可以正常工作了。