Kali 2020.3 が完全にアップグレードされた後、ModuleNotFound 'ConfigParser'

Kali 2020.3 が完全にアップグレードされた後、ModuleNotFound 'ConfigParser'

1つを作成しましたsudo apt update && sudo apt full-upgrade -yが、次のエラーが発生しました。

File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \

File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'

この記事を読んだ後、私はこれがどこかで手動で操作することに関連していると思います/usr/bin(今読んだので決して行われたことはありませんが、過去に行われたことを覚えていません...)。ディストリビューションに必要なデフォルトのPythonバージョンです。

システムのPython側で見ることができる内容は次のとおりです。は /usr/bin/pythonへのリンクでありpython2 、  python2はへのリンクですpython2.7

わかりませんが、これは正しいバージョンを指していますか?上記のエラーにも関連していますか?

システムバージョンとPythonの位置情報を含むスクリーンショット

sudo apt -f --reinstall install python-configparser

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 62.6 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://kali.download/kali kali-rolling/main amd64 python-configparser all 3.5.0b2-3 [62.6 kB]
Fetched 62.6 kB in 1s (57.7 kB/s)            
(Reading database ... 402234 files and directories currently installed.)
Preparing to unpack .../python-configparser_3.5.0b2-3_all.deb ...
Unpacking python-configparser (3.5.0b2-3) over (3.5.0b2-3) ...
Setting up mercurial-common (5.4.1-1) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
dpkg: error processing package mercurial-common (--configure):
 installed mercurial-common package post-installation script subprocess returned error exit status 1
Setting up python-configparser (3.5.0b2-3) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
dpkg: error processing package python-configparser (--configure):
 installed python-configparser package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mercurial:
 mercurial depends on mercurial-common (= 5.4.1-1); however:
  Package mercurial-common is not configured yet.

dpkg: error processing package mercurial (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mercurial-common
 python-configparser
 mercurial

8月4日更新:解決したようです。さまざまな他のフォーラムなどをフォローし、多くの実験を行った後に更新するだけです。 :-).何も動作しません。
したがって、すべてのPythonとPythonの最小パッケージでapt-cache rdependentsコマンドを試した結果、python2.7は出力に重複するエントリを表示することがよくあります。その後、dpkg -Vとpython2を最小化しようとしましたが、基本的に奇妙な出力が出ました。そのうちのいくつかは何ですか?左側にpycompileが言及されていますが(当時はスクリーンショットがないので申し訳ありませんが)、出力が表示された唯一のファイルであり、当時はpython2.7が壊れている可能性があると思いました。したがって、次のように進みます。
私の/usr/bin/pythonを次のようにpython3に接続します. sudo ln -s /usr/bin/python3 /usr/bin/python 次に、バージョンが次のようにどこかを指していることを確認します。 python - バージョン。次に、apt autoremoveのようにaotoremoveを実行し、
最後にsudo apt purge -y python2.7-minimalなどの2.7最小バージョンを削除しました。ついに問題なくaptを使用できるようになりました。そして、sudo dpkg --force-all --configure -aと一緒にapt cleanを実行しましたが、これまではすべて大丈夫です。だからすぐに電源を切ってVMのスナップショットを撮った後、正常に起動しました。 python2.7を再インストールする必要があるかどうか後で確認してください...

PS! Pythonは将来、これらの以前のバージョンとの互換性の問題に遭遇するでしょうか?この質問のウェブ検索中に、以前のバージョンとの互換性の問題に関連しているように思われる多くの問題が見つかりました。 (そうであれば、Pythonを学ぶ計画をあきらめる必要があるようです。特にPythonを学ぼうとしているからです。組み合わせる方が良いかもしれません。

ヒントと助けてくれた皆さんに感謝します。 2.7で問題が発生した場合は更新します。

ベストアンサー1

おすすめ記事