0

Sorry my OS is in french so i hope it will not an issue for you guys.

I had some trouble with python and awx install so i decided to delete all python package but i have done big foolishness. Now i cannot even install package like vim. I have followed on post to clean python that's why i have done all steps below.

2666 24/04/19 10:27:03 rm -rf ~/.local/lib/python*
2733 24/04/19 10:45:34 rm -rf python*
2734 24/04/19 10:45:38 sudorm -rf python*
2736 24/04/19 10:46:02 sudo rm -rf python2.7 python3 python3.5
2748 24/04/19 10:46:47 rm -rf python2.7 libpython2.7.a python3.5
2749 24/04/19 10:46:50 sudo rm -rf python2.7 libpython2.7.a python3.5
2754 24/04/19 10:47:02 sudo rm -rf pkgconfig/

I have tried below command

user@user:/usr/bin$ sudo apt-get install python3-minimal
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
python3-minimal est déjà la version la plus récente (3.5.1-3).
0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.
5 partiellement installés ou enlevés.
Après cette opération, 0 o d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer*? [O/n] o
Paramétrage de python3 (3.5.1-3) ...
running python rtupdate hooks for python3.5...
/usr/share/python3/runtime.d/dh-python.rtupdate: 5: /usr/share/python3/runtime.d/dh-python.rtupdate: py3clean: not found
error running python rtupdate hook dh-python
dpkg: erreur de traitement du paquet python3 (--configure)*:
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 4
Paramétrage de python3.5-minimal (3.5.2-2ubuntu0~16.04.5) ...
/var/lib/dpkg/info/python3.5-minimal.postinst: 46: /var/lib/dpkg/info/python3.5-minimal.postinst: /usr/bin/python3.5: not found
dpkg: erreur de traitement du paquet python3.5-minimal (--configure)*:
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
Paramétrage de python2.7-minimal (2.7.12-1ubuntu0~16.04.4) ...
/var/lib/dpkg/info/python2.7-minimal.postinst: 42: /var/lib/dpkg/info/python2.7-minimal.postinst: /usr/bin/python2.7: not found
dpkg: erreur de traitement du paquet python2.7-minimal (--configure)*:
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
dpkg: des problèmes de dépendances empêchent la configuration de python-minimal*:
 python-minimal dépend de python2.7-minimal (>= 2.7.12-1~)*; cependant*:
 Le paquet python2.7-minimal n'est pas encore configuré.

dpkg: erreur de traitement du paquet python-minimal (--configure)*:
 problèmes de dépendances - laissé non configuré
dpkg: des problèmes de dépendances empêchent la configuration de python2.7*:
 python2.7 dépend de python2.7-minimal (= 2.7.12-1ubuntu0~16.04.4)*; cependant*:
 Le paquet python2.7-minimal n'est pas encore configuré.

dpkg: erreur de traitement du paquet python2.7 (--configure)*:
 problèmes de dépendances - laissé non configuré
Des erreurs ont été rencontrées pendant l'exécution*:
 python3
 python3.5-minimal
 python2.7-minimal
 python-minimal
 python2.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried this command too

        sudo dpkg --force-all --configure -a
Paramétrage de python3 (3.5.1-3) ...
running python rtupdate hooks for python3.5...
/usr/share/python3/runtime.d/dh-python.rtupdate: 5: /usr/share/python3/runtime.d/dh-python.rtupdate: py3clean: not found
error running python rtupdate hook dh-python
dpkg: erreur de traitement du paquet python3 (--configure) :
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 4
Paramétrage de python3.5-minimal (3.5.2-2ubuntu0~16.04.5) ...
/var/lib/dpkg/info/python3.5-minimal.postinst: 46: /var/lib/dpkg/info/python3.5-minimal.postinst: /usr/bin/python3.5: not found
dpkg: erreur de traitement du paquet python3.5-minimal (--configure) :
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
Paramétrage de python2.7-minimal (2.7.12-1ubuntu0~16.04.4) ...
/var/lib/dpkg/info/python2.7-minimal.postinst: 42: /var/lib/dpkg/info/python2.7-minimal.postinst: /usr/bin/python2.7: not found
dpkg: erreur de traitement du paquet python2.7-minimal (--configure) :
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
dpkg: python2.7 : problèmes de dépendances, mais configuration comme demandé :
 python2.7 dépend de python2.7-minimal (= 2.7.12-1ubuntu0~16.04.4) ; cependant :
 Le paquet python2.7-minimal n'est pas encore configuré.

Paramétrage de python2.7 (2.7.12-1ubuntu0~16.04.4) ...
/var/lib/dpkg/info/python2.7.postinst: 9: /var/lib/dpkg/info/python2.7.postinst: /usr/bin/python2.7: not found
dpkg: erreur de traitement du paquet python2.7 (--configure) :
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
dpkg: python-minimal : problèmes de dépendances, mais configuration comme demandé :
 python-minimal dépend de python2.7-minimal (>= 2.7.12-1~) ; cependant :
 Le paquet python2.7-minimal n'est pas encore configuré.

Paramétrage de python-minimal (2.7.12-1~16.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: erreur de traitement du paquet python-minimal (--configure) :
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 1
Des erreurs ont été rencontrées pendant l'exécution :
 python3
 python3.5-minimal
 python2.7-minimal
 python2.7
 python-minimal

Installation test Vim

sudo apt install vim
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
vim est déjà la version la plus récente (2:7.4.1689-3ubuntu1.2).
0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.
5 partiellement installés ou enlevés.
Après cette opération, 0 o d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer*? [O/n] o
Paramétrage de python3 (3.5.1-3) ...
running python rtupdate hooks for python3.5...
/usr/share/python3/runtime.d/dh-python.rtupdate: 5: /usr/share/python3/runtime.d/dh-python.rtupdate: py3clean: not found
error running python rtupdate hook dh-python
dpkg: erreur de traitement du paquet python3 (--configure)*:
le sous-processus script post-installation installé a retourné une erreur de sortie d'état 4
Paramétrage de python3.5-minimal (3.5.2-2ubuntu0~16.04.5) ...
/var/lib/dpkg/info/python3.5-minimal.postinst: 46: /var/lib/dpkg/info/python3.5-minimal.postinst: /usr/bin/python3.5: not found
dpkg: erreur de traitement du paquet python3.5-minimal (--configure)*:
le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
Paramétrage de python2.7-minimal (2.7.12-1ubuntu0~16.04.4) ...
/var/lib/dpkg/info/python2.7-minimal.postinst: 42: /var/lib/dpkg/info/python2.7-minimal.postinst: /usr/bin/python2.7: not found
dpkg: erreur de traitement du paquet python2.7-minimal (--configure)*:
le sous-processus script post-installation installé a retourné une erreur de sortie d'état 127
dpkg: des problèmes de dépendances empêchent la configuration de python-minimal*:
python-minimal dépend de python2.7-minimal (>= 2.7.12-1~)*; cependant*:
Le paquet python2.7-minimal n'est pas encore configuré.

dpkg: erreur de traitement du paquet python-minimal (--configure)*:
problèmes de dépendances - laissé non configuré
dpkg: des problèmes de dépendances empêchent la configuration de python2.7*:
python2.7 dépend de python2.7-minimal (= 2.7.12-1ubuntu0~16.04.4)*; cependant*:
Le paquet python2.7-minimal n'est pas encore configuré.

dpkg: erreur de traitement du paquet python2.7 (--configure)*:
problèmes de dépendances - laissé non configuré
Des erreurs ont été rencontrées pendant l'exécution*:
python3
python3.5-minimal
python2.7-minimal
python-minimal
python2.7
E: Sub-process /usr/bin/dpkg returned an error code (1)

Thanks for help

EDIT: I have tried to install package manually and i have new issue reported

  sudo dpkg -i --force-overwrite python3.5-minimal_3.5.2-2ubuntu0~16.04.5_amd64.deb
(Reading database ... 165302 files and directories currently installed.)
Preparing to unpack python3.5-minimal_3.5.2-2ubuntu0~16.04.5_amd64.deb ...
Unpacking python3.5-minimal (3.5.2-2ubuntu0~16.04.5) over (3.5.2-2ubuntu0~16.04.5) ...
Setting up python3.5-minimal (3.5.2-2ubuntu0~16.04.5) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

Current thread 0x00007f1cf2fef700 (most recent call first):
Aborted
dpkg: error processing package python3.5-minimal (--install):
 subprocess installed post-installation script returned error exit status 134
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
 python3.5-minimal
1
  • Use LANG=C before apt command to make the output English.
    – Liso
    Apr 24, 2019 at 10:28

1 Answer 1

3

You have 2 problems now

  • Ubuntu is heavily dependant on Python and you have almost completely removed Python from your system.
  • You manually removed Python using the rm command instead of removing it with apt (or dpkg)

Since you didn't go through the uninstallation process properly, it seems that your package manager now thinks that you have python installed, but not configured (which isn't the case). And you seem to be getting some dependency problems with some python packages, and you need to reinstall them:

  • python3
  • python3.5-minimal
  • python2.7-minimal
  • python-minimal
  • python2.7

I cannot try myself in order to let you know which option will fix your problem, but I'll give you 3 solutions. Starting with the easiest one. I recommend taking backup for any needed files as you currently have a broken system, and the following solution may not end up fixing it.

  1. Try and let apt fix your dependencies by itself with the following command:

    sudo apt install -f
    
  2. Force install the packages with apt (ref):

    sudo apt -o Dpkg::Options::="--force-overwrite" install python3 python3.5-minimal python2.7-minimal python-minimal python2.7
    
  3. Install them manually with dpkg.
    From the output above, I assume you are using 16.04. If not, just change the version before downloading the packages.

    Download each broken package from https://packages.ubuntu.com and force install it manually with dpkg.

    sudo dpkg -i --force-overwrite /path/to/downloaded/package
    

Notes:

  • P.S. After installing them, it's possible you may get other errors with other python packages. Just restart the process mentioned but for those new packages.
  • P.S.S The --force-overwrite flag is most likely needed in order to force dpkg to install the packages even if it thinks that they are already installed.
1
  • Perfect explaination, I have tried everything but I have the same issue. I will try to install all package but there are a lot of dependencies for all package, It will be very long.
    – rab boubou
    Apr 25, 2019 at 8:00

Not the answer you're looking for? Browse other questions tagged .