Supprimé le binaire python et ne peut pas récupérer en utilisant apt-get, que puis-je faire?


11

Bien. Oui. Je voulais un nouveau départ parce que j'avais des confusions de dépendances, j'ai donc exécuté "whereis python" et effacé littéralement tous les fichiers et répertoires qui se sont présentés. Ensuite, lorsque je lance ppton apt-get install, j'obtiens bien sûr beaucoup d'erreurs. Existe-t-il un moyen de réinstaller python sur Ubuntu sans simplement effacer?

Voici le résultat de la tentative d'installation du binaire 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)

Après avoir parcouru l'itinéraire proposé par 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)

python : Depends: python2.7 (>= 2.7.5-1~) but it is not going to be installed. Je pense que vos précédents conflits de dépendance vous préoccupent toujours. Pouvez-vous également donner la sortie dedpkg -l | grep python
cnvzmxcvmcx

Réponses:


20

À l'avenir, ne faites pas ça. Ne supprimez pas manuellement (ou ne salissez pas) les fichiers installés via les outils de gestion de packages (sauf s'ils sont explicitement configurés pour cela, comme les fichiers de configuration, etc.).

Cela étant dit, si vous ne parvenez pas (et il semble que ce soit le cas) à utiliser apt-getpour récupérer de cette situation car certaines parties du processus s'attendent à ce que python soit déjà installé, vous avez quelques options (pas toutes fonctionnera nécessairement).

Vous pouvez récupérer les .debfichiers python (et les fichiers associés) manuellement et tenter de les utiliser dpkgpour les installer manuellement (vous devrez résoudre manuellement l'ordre de dépendance pour vous assurer que cela fonctionne correctement). Quelque chose comme:

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*

Vous devez vérifier les autres fichiers binaires manquants, comme pycompile, et appliquer la même solution.

Après cela, il est recommandé de vérifier la base de données dpkg à la recherche de packages non configurés, semi-configurés et simplement décompressés:

sudo dpkg --check

Lisez les messages et appliquez les correctifs, mais normalement cela demanderait sudo dpkg --configure -a. Un sudo apt-get -f installpourrait aider en fonction de la situation.

Vous pouvez également utiliser un mode de récupération (ou réinstallation) du support d'installation pour résoudre ce problème.


4

Existe-t-il un moyen de réinstaller python sur Ubuntu sans simplement effacer?

Oui. Réinstallez sans formatage.

Ce sera également la méthode la plus rapide pour résoudre ce problème, car vous avez probablement déjà un DVD Live.


3
La réinstallation d'ubuntu semble un peu exagérée dans ce cas.
ike

2
Puisque presque tout dépend de python et que "apt" ne fonctionnera plus (en raison des dépendances de python), toute autre méthode prendra beaucoup plus de temps. Une réinstallation sans format prend environ 10, 15 minutes sur une machine actuelle. @ike
Rinzwind

3
apt devrait fonctionner pour d'autres packages, mais pas pour python. Il n'est pas trop difficile de résoudre ce problème en réinstallant chaque package.
ike

1
La suppression d'un système binaire peut être cataclysmique, mais ce n'est pas la fin du monde. Vous pouvez le supprimer rmet le récupérer facilement . Python n'est qu'une promenade dans le parc.
Braiam

1

Ouvrez un terminal et saisissez les commandes suivantes:

Premier essai

sudo apt-get -f install 

Si cela ne fonctionne pas, essayez

sudo dpkg --configure -a 

Si vous rencontrez toujours des problèmes, exécutez

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

En dernier recours, vous devrez peut-être supprimer ces packages avec la commande suivante, puis réinstaller ces packages à l'aide de la commande ci-dessus. Si tel est le cas, vous devrez faire très attention. Il y aura une liste de packages désinstallés avec la commande suivante. Vous devrez copier cette liste et la coller dans gedit. Avec gedit ouvert et la liste des packages collés dans gedit, appuyez sur ctrl+ het entrez \ n suivi de deux espaces dans "Rechercher" et d'un espace dans "Remplacer par" pour supprimer tous les paragraphes et espaces supplémentaires avant de cliquer sur remplacer tout pour que votre liste contient une liste de packages séparés uniquement par des espaces simples.

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

Enfin, exécutez: sudo apt-get installet collez la liste des packages de gedit pour tout réinstaller.


Je suis presque certain que tous les packages python- * sont inclus dans le méta-package python. OP n'aurait pas besoin d'établir et de maintenir une liste de packages à (dés) / installer. apt-get install --reinstall pythondevrait le couvrir.
amanthethy

@amanthethy la "liste" que je mentionne est les centaines d'autres packages qui peuvent également être désinstallés tels que l'unité, toutes les étendues, le gestionnaire de comptes, etc. .
mchid

1
Non, cela ne fera de mal à personne - à part l'étrange tunnel carpel - mais ce n'est pas nécessaire. En outre, python-pip est un gestionnaire de packages pour les programmes python. C'est une application construite en python et non une fonctionnalité du langage lui-même.
amanthethy

1
sudo apt-get install --reinstall ubuntu-desktopcouvrira tous les extras que vous avez mentionnés. [unité, étendues, python, gestionnaire de comptes, etc.]
amanthethy

1
Pas de soucis mec. Les votes négatifs ne signifient pas grand-chose pour moi tant que nous sommes en mesure d'aider le PO :)
amanthethy

0

Vous devez supprimer chaque package qui vous pose problème, puis les réinstaller.

Voir /ubuntu//a/32899/176376 pour la suppression sans supprimer les dépendances.

sudo dpkg -r --force-depends "package"

sudo apt-get install "package"

Vous devez d'abord supprimer tous les problèmes, puis les réinstaller.

Exécutez un sudo apt-get install -fet sudo dpkg --configure -atous les quelques commandes.


0

Je vois que vous avez des erreurs comme celle-ci:

python2.7: not found

Cela signifie que l'exécutable python 2.7 est introuvable. J'ai utilisé ces commandes pour trouver le paquet qui le contient (cela ne fonctionnerait probablement pas sur votre système cassé, cependant)

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

Vous devez le réinstaller, mais vous devez d'abord parcourir ses dépendances. Utilisez ces commandes pour les répertorier:

$ 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 est probablement endommagé. Je vous recommande donc de commencer par émettre:

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

puis:

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

puis j'espère que votre

sudo apt-get -f install

allons réussir.


-1

C'est un comportement attendu. La suppression de fichiers n'est pas la même chose que la désinstallation d'un package ou d'un programme.

Vous avez supprimé tous les éléments liés à python de votre installation, mais votre gestionnaire de packages ne le sait pas. Lorsque vous allez réinstaller Python, apt s'attend à ce que tous ces fichiers soient toujours là et ne prend pas la peine d'essayer de les télécharger à nouveau. En ce qui concerne apt, tout python est toujours installé; Vous ne l'avez jamais dit autrement.

Vous pouvez essayer ce qui suit pour tenter de corriger cela:
sudo apt-get install --reinstall python

À l'avenir, désinstallez les packages en utilisant apt-get removeou apt-get purgeou graphiquement à partir du Centre logiciel Ubuntu.


3
Une purge de python désinstalle de nombreuses dépendances, où la réinstallation ne réinstalle pas toutes celles-ci.
oldfred

1
Vous avez raison jusqu'au deuxième paragraphe. Votre méthode de «correction» du problème pourrait simplement supprimer la plupart des paquets du système OP.
Braiam

@Braiam Vous avez raison. Je tenais pour acquis que le package de suppression apt-get peut désinstaller des packages que le package d'installation apt-get ne restaurera pas nécessairement. J'ai édité, mais n'hésitez pas à le corriger si je ne suis toujours pas en ligne.
amanthethy
En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.