web-dev-qa-db-ja.com

pythonバイナリを削除しましたが、apt-getを使用して回復できません。どうすればよいですか?

まあ。うん。依存関係が混乱しているため、新たなスタートを望んでいたので、「whereis python」を実行し、出てきたすべてのファイルとディレクトリを文字通り消去しました。次に、apt-get install pythonを実行すると、もちろん多くのエラーが発生します。クリーンワイプを行わずにUbuntuにpythonを再インストールする方法はありますか?

pythonバイナリをインストールしようとした場合の出力は次のとおりです。

root@ubuntu14-server:/home/kpoole# apt-get install python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python is already the newest version.
The following packages were automatically installed and are no longer required:
libexpat1-dev libpython-dev libpython2.7-dev
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
15 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-chardet (2.0.1-2build2) ...
/var/lib/dpkg/info/python-chardet.postinst: 6: /var/lib/dpkg/info/python-chardet.postinst: pycompile: not found
dpkg: error processing package python-chardet (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up python-colorama (0.2.5-0.1ubuntu1) ...
/var/lib/dpkg/info/python-colorama.postinst: 6: /var/lib/dpkg/info/python-colorama.postinst: pycompile: not found
dpkg: error processing package python-colorama (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up python-distlib (0.1.8-1) ...
/var/lib/dpkg/info/python-distlib.postinst: 6: /var/lib/dpkg/info/python-distlib.postinst: pycompile: not found
dpkg: error processing package python-distlib (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up python-Django (1.6.1-2ubuntu0.5) ...
/var/lib/dpkg/info/python-Django.postinst: 6: /var/lib/dpkg/info/python-Django.postinst: pycompile: not found
dpkg: error processing package python-Django (--configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-Django-tables2:
python-Django-tables2 depends on python-Django (>= 1.4.5); however:
Package python-Django is not configured yet.

dpkg: error processing package python-Django-tables2 (--configure):
dependency problems - leaving unconfigured
Setting up python-six (1.5.2-1) ...
No apport report written because MaxReports is reached already
                                              /var/lib/dpkg/info/python-six.postinst: 6: /var/lib/dpkg/info/python-six.postinst: pycompile: not found
dpkg: error processing package python-six (--configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-html5lib:
python-html5lib depends on python-six; however:
Package python-six is not configured yet.

dpkg: error processing package python-html5lib (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                              Setting up python-lxml (3.3.3-1ubuntu0.1) ...
/var/lib/dpkg/info/python-lxml.postinst: 6: /var/lib/dpkg/info/python-lxml.postinst: pycompile: not found
dpkg: error processing package python-lxml (--configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                              Setting up python-minimal (2.7.5-5ubuntu3) ...
/var/lib/dpkg/info/python-minimal.postinst: 4: /var/lib/dpkg/info/python-minimal.postinst: python2.7: not found
dpkg: error processing package python-minimal (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up python-pkg-resources (3.3-1ubuntu1) ...
No apport report written because MaxReports is reached already
                                              /var/lib/dpkg/info/python-pkg-resources.postinst: 6: /var/lib/dpkg/info/python-pkg-resources.postinst: pycompile: not found
dpkg: error processing package python-pkg-resources (--configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-setuptools:
python-setuptools depends on python-pkg-resources (= 3.3-1ubuntu1); however:
Package python-pkg-resources is not configured yet.

dpkg: error processing package python-setuptools (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-urllib3:
python-urllib3 depends on python-six; however:
Package python-six is not configured yet.

dpkg: error processing package python-urllib3 (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-requests:
python-requests depends on python-chardet; however:
Package python-chardet is not configured yet.
python-requests depends on python-urllib3 (>= 1.7.1); however:
Package python-urllib3 is not configured yet.

dpkg: error processing package python-requests (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-pip:
python-pip depends on python-colorama; however:
Package python-colorama is not configured yet.
python-pip depends on python-distlib; however:
Package python-distlib is not configured yet.
python-pip depends on python-html5lib; however:
Package python-html5lib is not configured yet.
python-pip depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
python-pip depends on python-setuptools (>= 0.6c1); however:
Package python-setuptools is not configured yet.
python-pip depends on python-six; however:
Package python-six is not configured yet.
python-pip depends on python-requests; however:
Package python-requests is not configured yet.

dpkg: error processing package python-pip (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                              dpkg: dependency problems prevent configuration of python-virtualenv:
python-virtualenv depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
python-virtualenv depends on python-setuptools; however:
Package python-setuptools is not configured yet.

dpkg: error processing package python-virtualenv (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                              Errors were encountered while processing:
python-chardet
python-colorama
python-distlib
python-Django
python-Django-tables2
python-six
python-html5lib
python-lxml
python-minimal
python-pkg-resources
python-setuptools
python-urllib3
python-requests
python-pip
python-virtualenv
E: Sub-process /usr/bin/dpkg returned an error code (1)

ikeが提案するルートを行った後:

root@ubuntu14-server:/home/kpoole# apt-get install --reinstall python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
python : Depends: python2.7 (>= 2.7.5-1~) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
root@ubuntu14-server:/home/kpoole# apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
libexpat1-dev libpython-dev libpython2.7-dev
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
python python2.7
Suggested packages:
python-doc python-tk python2.7-doc
The following NEW packages will be installed:
python python2.7
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
14 not fully installed or removed.
Need to get 0 B/330 kB of archives.
After this operation, 1,042 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package python2.7.
(Reading database ... 73738 files and directories currently installed.)
Preparing to unpack .../python2.7_2.7.6-8_AMD64.deb ...
Unpacking python2.7 (2.7.6-8) ...
Selecting previously unselected package python.
Preparing to unpack .../python_2.7.5-5ubuntu3_AMD64.deb ...
Unpacking python (2.7.5-5ubuntu3) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for mime-support (3.54ubuntu1) ...
Setting up python-minimal (2.7.5-5ubuntu3) ...
/var/lib/dpkg/info/python-minimal.postinst: 4: /var/lib/dpkg/info/python-minimal.postinst: python2.7: not found
dpkg: error processing package python-minimal (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up python2.7 (2.7.6-8) ...
/var/lib/dpkg/info/python2.7.postinst: 9: /var/lib/dpkg/info/python2.7.postinst: python2.7: not found
dpkg: error processing package python2.7 (--configure):
subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python:
python depends on python2.7 (>= 2.7.5-1~); however:
Package python2.7 is not configured yet.
python depends on python-minimal (= 2.7.5-5ubuntu3); however:
Package python-minimal is not configured yet.

dpkg: error processing package python (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-chardet:
python-chardet depends on python (>= 2.7); however:
Package python is not configured yet.
python-chardet depends on python (<< 2.8); however:
Package python is not configured yet.
python-chardet depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.

dpkg: error processing package python-chardet (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-colorama:
python-colorama depends on python (>= 2.7); however:
Package python is not configured yet.
python-coNo apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
        No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
                    lorama depends on python (<< 2.8); however:
Package python is not configured yet.
python-colorama depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.

dpkg: error processing package python-colorama (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-distlib:
python-distlib depends on python:any (<< 2.8); however:
Package python is not configured yet.
python-distlib depends on python:any (>= 2.7.5-5~); however:
Package python is not configured yet.

dpkg: error processing package python-distlib (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-Django:
python-Django depends on python (>= 2.7); however:
Package python is not configured yet.
python-Django depends on python (<< 2.8); however:
Package python is not configured yet.
python-Django depends on python:any (>= 2.7.1-0ubuntu2); however:
Package pythNo apport report written because MaxReports is reached already
on is not configured yet.

dpkg: error processing package python-Django (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-Django-tables2:
python-Django-tables2 depends on python (>= 2.7); however:
Package python is not configured yet.
python-Django-tables2 depends on python (<< 2.8); however:
Package python is not configured yet.
python-Django-tables2 depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.
python-Django-tables2 depends on python-Django (>= 1.4.5); however:
Package python-Django is not configured yet.

dpkg: error processing package python-Django-tables2 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-six:
python-six depends on python (>= 2.7); however:
Package python is not configured yet.
python-six depends on python (<< 2.8); however:
Package python is not configured yet.
python-six depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.

dpkg: error processing package python-six (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-html5lib:
python-html5lib depends on python:any (<< 2.8); however:
Package python is not configured yet.
python-html5lib depends on python:any (>= 2.7.5-5~); however:
Package python is not configured yet.
python-html5lib depends on python-six; however:
Package python-six is not configured yet.

dpkg: error processing package python-html5lib (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-lxml:
python-lxml depends on python (>= 2.7); however:
Package python is not configured yet.
python-lxml depends on python (<< 2.8); however:
Package python is not configured yet.
python-lxml depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.

dpkg: error processing package python-lxml (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-pkg-resources:
python-pkg-resources depends on python:any (>= 2.7); however:
Package python is not configured yet.
python-pkg-resources depends on python:any (<< 2.8); however:
Package python is not configured yet.

dpkg: error processing package python-pkg-resources (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-setuptools:
python-setuptools depends on python:any (>= 2.7); however:
Package python is not configured yet.
python-setuptools depends on python:any (<< 2.8); however:
Package python is not configured yet.
python-setuptools depends on python-pkg-resources (= 3.3-1ubuntu1); however:
Package python-pkg-resources is not configured yet.

dpkg: error processing package python-setuptools (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-urllib3:
python-urllib3 depends on python:any (>= 2.7.5-5~); however:
Package python is not configured yet.
python-urllib3 depends on python:any (<< 2.8); however:
Package python is not configured yet.
python-urllib3 depends on python-six; however:
Package python-six is not configured yet.

dpkg: error processing package python-urllib3 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-requests:
python-requests depends on python:any (>= 2.7.5-5~); however:
Package python is not configured yet.
python-requests depends on python:any (<< 2.8); however:
Package python is not configured yet.
python-requests depends on python-chardet; however:
Package python-chardet is not configured yet.
python-requests depends on python-urllib3 (>= 1.7.1); however:
Package python-urllib3 is not configured yet.

dpkg: error processing package python-requests (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-pip:
python-pip depends on python (>= 2.7); however:
Package python is not configured yet.
python-pip depends on python (<< 2.8); however:
Package python is not configured yet.
python-pip depends on python:any (>= 2.7.1-0ubuntu2); however:
Package python is not configured yet.
python-pip depends on python-colorama; however:
Package python-colorama is not configured yet.
python-pip depends on python-distlib; however:
Package python-distlib is not configured yet.
python-pip depends on python-html5lib; however:
Package python-html5lib is not configured yet.
python-pip depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
python-pip depends on python-setuptools (>= 0.6c1); however:
Package python-setuptools is not configured yet.
python-pip depends on python-six; however:
Package python-six is not configured yet.
python-pip depends on python-requests; however:
Package python-requests is not c
dpkg: error processing package python-pip (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python-minimal
python2.7
python
python-chardet
python-colorama
python-distlib
python-Django
python-Django-tables2
python-six
python-html5lib
python-lxml
python-pkg-resources
python-setuptools
python-urllib3
python-requests
python-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
10
pooley1994

将来これをしないでください。パッケージ管理ツールを介してインストールされたファイルを手動で削除しないでください(または、構成ファイルなどのように明示的にセットアップされていない限り)。

pythonが既にインストールされていることを期待するプロセスの一部があるため、apt-getを使用してこの状況から回復することができない場合(そして、これが事実であるように見える場合)次に、いくつかのオプションがあります(必ずしもすべてが機能するとは限りません)。

python(および関連する).debファイルを手動で取得し、dpkgを使用して手動でインストールすることを試みることができます(依存関係の順序を手動で解決してこれを確認する必要があります)正常に動作します)。何かのようなもの:

apt-get download python2.7-minimal ## at least this package is necessary
Sudo touch /usr/bin/python2.7 && Sudo chmod +x /usr/bin/python2.7
Sudo dpkg --unpack python2.7-minimal*

pycompileなどの他の不足しているバイナリを確認し、同じソリューションを適用する必要があります。

この後、dpkgデータベースをチェックして、構成されていない、半分構成された、解凍されたパッケージを探すことをお勧めします。

Sudo dpkg --check

メッセージを読んで修正を適用しますが、通常はSudo dpkg --configure -aを要求します。 Sudo apt-get -f installは状況に応じて役立ちます。

これを修正するために、インストールメディアリカバリモード(または再インストール)を使用できる場合もあります。

17
Etan Reisner

クリーンワイプを行わずにUbuntuにpythonを再インストールする方法はありますか?

はい。フォーマットせずに再インストールします。

おそらく、すでにLive DVDを持っているので、これを修正する最も速い方法にもなります。

4
Rinzwind

ターミナルを開き、次のコマンドを入力します。

初挑戦

Sudo apt-get -f install 

それでもうまくいかない場合は、試してください

Sudo dpkg --configure -a 

まだ問題がある場合は、実行してください

Sudo apt-get install --reinstall python python-chardet python-colorama python-distlib python-Django python-Django-tables2 python-six python-html5lib python-lxml python-minimal python-pkg-resources python-setuptools python-urllib3 python-requests python-pip python-virtualenv

最後の手段として、次のコマンドでこれらのパッケージを削除してから、上記のコマンドを使用してこれらのパッケージを再インストールする必要がある場合があります。この場合、細心の注意を払う必要があります。次のコマンドでアンインストールされたパッケージのリストが表示されます。このリストをコピーして、geditに貼り付ける必要があります。 geditを開き、geditに貼り付けられたパッケージのリストで、を押します ctrl + h \ nを入力し、「検索」に2つのスペースと「置換」に1つのスペースを入力して、すべて置換する前にすべての段落と余分なスペースを削除して、リストに単一のスペースのみで区切られたパッケージのリストが含まれるようにします。

Sudo apt-get purge python-chardet python-colorama python-distlib python-Django python-Django-tables2 python-six python-html5lib python-lxml python-minimal python-pkg-resources python-setuptools python-urllib3 python-requests python-pip python-virtualenv

最後に:Sudo apt-get installを実行し、geditからパッケージのリストに貼り付けてすべてを再インストールします。

1
mchid

次のようなエラーが表示されます:

python2.7: not found

python 2.7実行可能ファイルが見つからないことを意味します。これらのコマンドを使用して、それを含むパッケージを見つけました(ただし、おそらく壊れたシステムでは動作しません)

$ which python2.7
/usr/bin/python2.7
$ dpkg -S /usr/bin/python2.7
python2.7-minimal: /usr/bin/python2.7

再インストールする必要がありますが、最初に依存関係を確認する必要があります。それらをリストするには、次のコマンドを使用します。

$ apt-cache depends python2.7-minimal
python2.7-minimal
  Depends: libpython2.7-minimal
  Depends: zlib1g
  PreDepends: libc6
  Suggests: binfmt-support
    binfmt-support:i386
  Recommends: python2.7
  Conflicts: binfmt-support
  Conflicts: binfmt-support:i386
  Replaces: python2.7
  Replaces: python2.7:i386
  Conflicts: python2.7-minimal:i386

libpython2.7-minimalはおそらく破損しています。だから、私はあなたに最初の問題を勧めます:

Sudo apt-get install --reinstall libpython2.7-minimal

その後:

Sudo apt-get install --reinstall python2.7-minimal

できればあなたの

Sudo apt-get -f install

成功します。

0
user362066

問題が発生する各パッケージを削除してから、再インストールする必要があります。

依存関係を削除せずに削除するには、 https://askubuntu.com/a/32899/176376 を参照してください。

Sudo dpkg -r --force-depends "package"

Sudo apt-get install "package"

最初に問題のあるものをすべて削除してから、再度インストールする必要があります。

いくつかのコマンドごとにSudo apt-get install -fおよびSudo dpkg --configure -aを実行します。

0
ike