Hello I am a BIG linux noobie that using debian stretch I getting errors when I am trying to install packages or delete packages

this is the error I get when I am trying to install packages with pip3

dsal3389@Dsal3389:~$ pip3 install django

Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'

Current thread 0x00007f90b31f3740 (most recent call first): Aborted

so I tried to delete python3 and install it later, and then I got this error

dsal3389@Dsal3389:~$ sudo apt purge python3

Reading package lists... Done Building dependency tree
Reading state information... Done The following packages were automatically installed and are no longer required: diffstat distro-info-data espeak-ng-data gir1.2-accountsservice-1.0 gir1.2-atspi-2.0 gir1.2-caribou-1.0 gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdm-1.0 gir1.2-git2-glib-1.0 gir1.2-gmenu-3.0 gir1.2-gnomebluetooth-1.0 gir1.2-grilo-0.3 gir1.2-gtk-2.0 gir1.2-gucharmap-2.90 gir1.2-mediaart-2.0 gir1.2-mutter-3.0 gir1.2-networkmanager-1.0 gir1.2-nmgtk-1.0 gir1.2-packagekitglib-1.0 gir1.2-polkit-1.0 gir1.2-rb-3.0 gir1.2-totem-1.0 gir1.2-totem-plparser-1.0 gir1.2-upowerglib-1.0 gir1.2-vte-2.91 gir1.2-wnck-3.0 gir1.2-zeitgeist-2.0 gnome-session-bin gnome-session-common gnome-software-common hyphen-en-us icu-devtools libappstream-glib8 libapt-pkg-perl libbrlapi0.6 libc6-dev:i386 libcairo-script-interpreter2 libcaribou-common libcaribou0 libcgi-fast-perl libcgi-pm-perl libclass-accessor-perl libclone-perl libdotconf0 libemail-valid-perl libespeak-ng1 libexporter-tiny-perl libfcgi-perl libfontconfig1-dev libfreetype6-dev libfwupd1 libgcab-1.0-0 libgdm1 libgit2-24 libgit2-glib-1.0-0 libgnome-menu-3-0 libgpod-common libgpod4 libgraphite2-dev libgspell-1-1 libgspell-1-common libgucharmap-2-90-7 libharfbuzz-gobject0 libhttp-parser2.1 libice-dev libicu-dev libio-pty-perl libio-string-perl libipc-run-perl liblist-moreutils-perl liblouis-data liblouis12 libncursesw6 libnet-dns-perl libnet-domain-tld-perl libnet-ip-perl libnm-gtk0 libparse-debianchangelog-perl libpcaudio0 libpcre3-dev libpcre32-3 libpcrecpp0v5 libperlio-gzip-perl libpixman-1-dev libpng-dev libpng-tools libpthread-stubs0-dev libpython3-dev libpython3-stdlib libpython3.5-dev libpython3.6-minimal libpython3.6-stdlib libreoffice-help-en-us libsgutils2-2 libsm-dev libsonic0 libspeechd2 libsub-name-perl libtext-levenshtein-perl libtinfo6 libx11-dev libx11-doc libxau-dev libxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev libyaml-libyaml-perl lintian linux-libc-dev:i386 patchutils pkg-config python-openssl python-requests python-urllib3 python3-minimal python3.5-dev python3.6-minimal speech-dispatcher speech-dispatcher-audio-plugins speech-dispatcher-espeak-ng t1utils x11proto-composite-dev x11proto-core-dev x11proto-damage-dev x11proto-fixes-dev x11proto-input-dev x11proto-kb-dev x11proto-randr-dev x11proto-render-dev x11proto-xext-dev x11proto-xinerama-dev xbrlapi xorg-sgml-doctools xtrans-dev xwayland zlib1g-dev Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: apt-listchanges* caribou* chrome-gnome-shell* dh-python* gdebi* gdebi-core* gdm3* gedit* gedit-common* gedit-plugins* gir1.2-ibus-1.0* gnome* gnome-core* gnome-menus* gnome-music* gnome-orca* gnome-session* gnome-shell* gnome-shell-extensions* gnome-software* libatk1.0-dev* libcairo2-dev* libgdk-pixbuf2.0-dev* libglib2.0-dev* libgtk2.0-dev* libharfbuzz-dev* libpango1.0-dev* libreoffice* libreoffice-librelogo* libreoffice-script-provider-python* libxfce4util-dev* lsb-release* python3* python3-apt* python3-brlapi* python3-cairo* python3-cffi-backend* python3-chardet* python3-crypto* python3-cryptography* python3-cups* python3-cupshelpers* python3-dbus* python3-debian* python3-debianbts* python3-dev* python3-gi* python3-gi-cairo* python3-httplib2* python3-idna* python3-keyring* python3-keyrings.alt* python3-louis* python3-mako* python3-markupsafe* python3-pip* python3-pkg-resources* python3-pyasn1* python3-pyatspi* python3-pycurl* python3-pysimplesoap* python3-reportbug* python3-requests* python3-secretstorage* python3-setuptools* python3-six* python3-smbc* python3-software-properties* python3-speechd* python3-uno* python3-urllib3* python3-wheel* python3-xdg* reportbug* rhythmbox-plugins* software-properties-common* software-properties-gtk* system-config-printer-common* system-config-printer-udev* task-gnome-desktop* totem-plugins* ufw* unattended-upgrades* unoconv* xfce4-panel-dev* 0 upgraded, 0 newly installed, 85 to remove and 0 not upgraded. After this operation, 118 MB disk space will be freed. Do you want to continue? [Y/n] y Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'

Current thread 0x00007f04e1fbb740 (most recent call first): Aborted E: Sub-process /usr/bin/apt-listchanges --apt || test $? -lt 10 returned an >error code (1) E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10

this just happened turn my computer on and get those staff

Python version

dsal3389@Dsal3389:~$ python3 -V

Python 3.5.3

  • 1
    added python 3.5.3 – dsal3389 Jun 6 '18 at 15:07

The package python3-pip is buggy and may break apt.

apt-listbugs list python3-pip
Retrieving bug reports... Done
Parsing Found/Fixed information... Done
serious bugs of python3-pip (-> ) <Resolved in some Version>
b1 - #896390 - python3-pip: pip fails to import (Fixed: python-pip/9.0.1-2.1)
 python3-pip(1 bug)

Set Python2.7 as default :

Add python* to update-alternatives:

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 40
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 30

Switch to python2.7:

update-alternatives --config python

Select python2.7.

Remove only the python3-pip package.

dpkg --configure -a
apt purge python3-pip

You can keep python3:

apt --reinstall install python3

Install apt-listbugs package to keep tracking the python3-pip, you can install it after the bug will be fixed.


Follow this answer posted by @Faheem Mitha to solve this error:

Could not find platform independent libraries <prefix> 
Could not find platform dependent libraries <exec_prefix> 
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 
  • still getting the same error when I'm trying to uninstall python3-pip – dsal3389 Jun 6 '18 at 15:33
  • still same error – dsal3389 Jun 6 '18 at 15:50
  • amm no I didn't – dsal3389 Jun 6 '18 at 15:59
  • @dsal3389 Sorry , I can understand , Please try to reinstall python3 then python3-pip : apt --reinstall install python3 then apt --reinstall python3-pip . – GAD3R Jun 6 '18 at 16:08
  • 1
    @GAD3R here there was the only place that I found the solution for this bug. Thank you very much!! – Francis Rodrigues Apr 15 '19 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.