破損した端子、ターミネータ、適切

破損した端子、ターミネータ、適切

Ubuntu 18.LTSがあり、誤ってトリガーされました。

代替アップデート --config python3.6

これで、ターミナル、ターミネーター、aptが機能しないように見え、システムが破損しているようです。

ターミネーター

Traceback (most recent call last):
  File "/usr/bin/terminator", line 23, in <module>
    import psutil
ModuleNotFoundError: No module named 'psutil'

端末

Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
ModuleNotFoundError: No module named 'gi'

簡単

たとえば、リポジトリを追加してみてください(3.5をインストールしてみましたが、これはすべてのプログラムのデフォルトであるようです)。

 internetmosquito@internetmosquito-PE72-7RD  ~  sudo add-apt-repository ppa:deadsnakes/ppa
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 12, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
ModuleNotFoundError: No module named 'softwareproperties'

今、私はpyenvを使ってさまざまなバージョンのPythonをインストールしたと言いたいと思います。

 ✘ internetmosquito@internetmosquito-PE72-7RD  ~  pyenv versions
  system
  2.7.13
* 3.8.3 (set by /home/internetmosquito/.pyenv/version)
  3.9-dev

ほとんどは/home/internetmosquito/.pyenv/versionsにインストールされます。

 internetmosquito@internetmosquito-PE72-7RD  ~  ls -ltra /home/internetmosquito/.pyenv/versions
total 20
drwxr-xr-x  6 internetmosquito internetmosquito 4096 jun 13  2020 3.9-dev
drwxr-xr-x  6 internetmosquito internetmosquito 4096 jun 16  2020 3.8.3
drwxrwxr-x 13 internetmosquito internetmosquito 4096 sep 27 20:35 ..
drwxr-xr-x  6 internetmosquito internetmosquito 4096 feb  9 01:05 2.7.13
drwxr-xr-x  5 internetmosquito internetmosquito 4096 feb  9 02:12 .

/usr/bin/pythonをチェックすると、次のようになります。

 internetmosquito@internetmosquito-PE72-7RD  ~  ls -ltra /usr/bin/python*
lrwxrwxrwx 1 root root      16 mar 13  2020 /usr/bin/python3-config -> python3.8-config
lrwxrwxrwx 1 root root       9 mar 13  2020 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root     388 mar 28  2020 /usr/bin/python3-pasteurize
-rwxr-xr-x 1 root root     384 mar 28  2020 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root     152 abr  9  2020 /usr/bin/python3-pbr
lrwxrwxrwx 1 root root      33 jul 28  2020 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
-rwxr-xr-x 1 root root 5486352 jul 28  2020 /usr/bin/python3.8
-rwxr-xr-x 1 root root 3629032 ago  4  2020 /usr/bin/python2.7
lrwxrwxrwx 1 root root      25 feb  8 23:49 /usr/bin/python3 -> /etc/alternatives/python3
lrwxrwxrwx 1 root root      24 feb  9 00:50 /usr/bin/python -> /etc/alternatives/python

Python 3.5を使用する「私の考えには」ターミネーターがないようです...

 internetmosquito@internetmosquito-PE72-7RD  ~  cat /usr/bin/terminator 
#!/usr/bin/python3

私のpython3の解析は実際に私のPythonと同じです...

 internetmosquito@internetmosquito-PE72-7RD  ~  python
Python 3.8.3 (default, Jun 16 2020, 18:30:59) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
 internetmosquito@internetmosquito-PE72-7RD  ~  python3
Python 3.8.3 (default, Jun 16 2020, 18:30:59) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

選択肢をもう一度更新しようとすると、このメッセージが表示されます。

 internetmosquito@internetmosquito-PE72-7RD  ~  sudo update-alternatives --config python3
There is only one alternative in link group python3 (providing /usr/bin/python3): /usr/local/bin/python3.7
Nothing to configure.

なぜ私はpython3.7が言及されているのかわかりませんか? /usr/local/binに複数のシルクヘビがあります。

✘ internetmosquito@internetmosquito-PE72-7RD  ~  ls -ltra /usr/local/bin/python*
lrwxrwxrwx 1 root root       17 dic 24  2018 /usr/local/bin/python3.7-config -> python3.7m-config
-rwxr-xr-x 2 root root 14925232 dic 24  2018 /usr/local/bin/python3.7m
-rwxr-xr-x 2 root root 14925232 dic 24  2018 /usr/local/bin/python3.7
-rwxr-xr-x 1 root root     3097 dic 24  2018 /usr/local/bin/python3.7m-config
-rwxr-xr-x 2 root root 14642520 feb  9 00:46 /usr/local/bin/python3.5m
-rwxr-xr-x 2 root root 14642520 feb  9 00:46 /usr/local/bin/python3.5
-rwxr-xr-x 1 root root     3071 feb  9 00:46 /usr/local/bin/python3.5m-config
lrwxrwxrwx 1 root root       17 feb  9 00:46 /usr/local/bin/python3.5-config -> python3.5m-config
lrwxrwxrwx 1 root root        9 feb  9 00:46 /usr/local/bin/python3 -> python3.5
lrwxrwxrwx 1 root root       16 feb  9 00:46 /usr/local/bin/python3-config -> python3.5-config

最も重要なのは、lsb_releaseも機能しないということです!

 internetmosquito@internetmosquito-PE72-7RD  ~  lsb_release -a                 
Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 25, in <module>
    import lsb_release
ModuleNotFoundError: No module named 'lsb_release'

どのように多くのものが破損しているのかわからない... Ubuntuを再インストールする必要があるという意味ではなく、正常に戻る方法についての提案はありますか?

ありがとうございます!

@Stewartの答えに基づいて更新されました。

私はここに投稿した結果を得るためにXtermを使用しています。ところで、私は20.04ではなく18.04にいます。

それからあなたの提案に戻って

 internetmosquito@internetmosquito-PE72-7RD  ~  file $(which terminator) $(which xterm) $(which gnome-terminal)
/usr/bin/terminator:     symbolic link to ../share/terminator/terminator
/usr/bin/xterm:          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=abd5692fa8891e01f24e8ae7f40f218662f098d9, for GNU/Linux 3.2.0, stripped
/usr/bin/gnome-terminal: Python script, ASCII text executable

私のgnome端末もPythonに基づいていると思いますか?

internetmosquito@internetmosquito-PE72-7RD  ~  file $(which add-apt-repository) $(which apt) $(which apt-cache) $(which dpkg)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c460d1db846110f4ae24cb54b4cfee967d022c09, for GNU/Linux 3.2.0, stripped
/usr/bin/apt-cache:          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2e75b0850b2936259281b093ecf906bf70a1d7b8, for GNU/Linux 3.2.0, stripped
/usr/bin/dpkg:               ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=978cfb3eb2e5cee720ae1c551c12595f1aa211f5, for GNU/Linux 3.2.0, stripped

適切な等を確認してください。

internetmosquito@internetmosquito-PE72-7RD  ~  file $(which add-apt-repository) $(which apt) $(which apt-cache) $(which dpkg)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c460d1db846110f4ae24cb54b4cfee967d022c09, for GNU/Linux 3.2.0, stripped
/usr/bin/apt-cache:          ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2e75b0850b2936259281b093ecf906bf70a1d7b8, for GNU/Linux 3.2.0, stripped
/usr/bin/dpkg:               ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=978cfb3eb2e5cee720ae1c551c12595f1aa211f5, for GNU/Linux 3.2.0, stripped

今Python 3を確認しようとすると

 internetmosquito@internetmosquito-PE72-7RD  ~  ls -go $(which python3)  
-rwxrwxr-x 1 424 jun 13  2020 /home/internetmosquito/.pyenv/shims/python3

したがって、pyenvがインストールしたPythonを指しているようです。

ベストアンサー1

まず、Pythonに依存しない端末を使用することをお勧めします。 gnome-terminalまたはxterm動作します:

$ file $(which terminator) $(which xterm) $(which gnome-terminal)
/usr/bin/terminator:     Python script, ASCII text executable
/usr/bin/xterm:          ELF 64-bit LSB pie executable, ...
/usr/bin/gnome-terminal: ELF 64-bit LSB pie executable, ...

、およびはadd-apt-repositoryPythonスクリプトかもしれませんが、それでも機能しません。aptdpkg

$ file $(which add-apt-repository) $(which apt) $(which apt-cache) $(which dpkg)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB pie executable, x86-...
/usr/bin/apt-cache:          ELF 64-bit LSB pie executable, x86-...
/usr/bin/dpkg:               ELF 64-bit LSB pie executable, x86-

apt一部の壊れたリンクを含む壊れたパッケージを再インストール/再構成するために使用できます。私はDebianでテストしていますが、DebianとUbuntuのコアPythonパッケージは同じ人が管理しているので、あなたにも似ているかどうか疑問です。ここで関連パッケージを探しています。

$ ls -go $(which python3) 
lrwxrwxrwx 1 9 Dec 23 07:05 /usr/bin/python3 -> python3.9

$ dpkg -S $(which python3) $(which python3.9)
python3-minimal: /usr/bin/python3
python3.9-minimal: /usr/bin/python3.9

$ apt-cache show python3 | grep Depends:
Depends: python3.9 (>= 3.9.1-1~), ...
Pre-Depends: python3-minimal (= 3.9.1-1)

$ apt-cache show python3.9 | grep Depends:
Depends: python3.9-minimal (= 3.9.1-4)...

これで、どのパッケージがこのリンクとそれに関連するバイナリを処理しているかを知っています。あなたの場合はUbuntu 20.04を使用しているので、python3.8代わりにpython3.9

私は以下を使用して問題を解決しようとします。

sudo apt reinstall python3 python3-minimal python3.8 python3.8-minimal

特別なことは、/var/lib/dpkg/info/<package>.{pre,post}{inst,rm}バイトのコンパイルと使用(該当する場合)を実行するスクリプトを再度呼び出すことですupdate-alternatives

これがうまくいかない場合は、出力を見てみましょうupdate-alternatives --config python3。 Debian テストでは、次のようになります。

$ update-alternatives --config python3
update-alternatives: error: no alternatives for python3

同じ結果を得ることは、代替案がもはやPython3を管理しないことを意味します。これがいつ変更されたのかはわかりません。理解できない場合は、これがコンピュータの問題の原因である可能性があります。古いpython3バージョンが削除された場合、prerm担当バージョンはupdate-alternatives --remove python3実行されません。実行して、update-alternatives --config python3どのオプションが利用可能かを確認してください。オプションがあり、python3.8優先順位が最も高い場合は、このオプションをもう一度実行してsudoを選択しますauto

$ update-alternatives --config python3
There are 3 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8      1111      auto mode
  1            /usr/bin/python3.5      1101      manual mode
  2            /usr/bin/python3.8      1111      manual mode
  3            /usr/bin/python3.7      1081      manual mode

しかし、私はpython3.8それがあなたのリストにないと思い、これがあなたに問題がある理由です。 Debian Buster(2018年にリリース)にもpython3.7があるので、python3.5はかなり古いです。パッケージはリンクを独自に管理するので、python3実行時にupdate-alternatives --config python3良いリンクを古いリンクに置き換えることができます。この場合、python3を手動で削除します。

sudo update-alternatives --remove-all python3

次に、Python パッケージを再インストールします。

新しいバージョンがリリースされるたびに、python3アーカイブのすべての依存パッケージに対してテストを実行するのに少し時間がかかります。パッケージが失敗した場合はバグレポートが送信され、管理者はパッケージが最新バージョンで動作することを確認するために最善を尽くしますpython3。通常、複数のポイントバージョンをインストールする必要はありません。 terminator最新python3。公式配布の範囲をterminator超えてpython3.5

おすすめ記事