2

I purged all the python3 packages and when I try to install python3 again on my raspbian I get this:

Setting up python3.5-minimal (3.5.3-1) ...
# Empty sitecustomize.py to avoid a dangling symlink
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 0x76fc8010 (most recent call first):
Aborted
dpkg: error processing package python3.5-minimal (--configure):
 subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of python3-minimal:
 python3-minimal depends on python3.5-minimal (>= 3.5.3-1~); however:
  Package python3.5-minimal is not configured yet.

dpkg: error processing package python3-minimal (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3.5-minimal
 python3-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

update:
I used sudo apt-get purge python3 and then used whereis python3 to find anything else that remains and i removed all of them.

When I try:

sudo apt-get –purge remove python3.5-minimal
sudo apt-get –purge remove python3-minimal
sudo apt-get autoremove –purge

I get this:

You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: dh-python : Depends: python3:any (>= 3.3.2-2~) lsb-release : Depends: python3:any (>= 3.4~) E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

With apt --fix-broken install I get the same error message.

What is the problem?

  • 2
    Would you please go into more detail, by editing the question as to how you purged the python packages, how you tested that they were gone, and and the command that you're using to try to bring them back. It will in getting an answer. – NomadMaker Aug 12 '18 at 23:22
  • I used sudo apt-get purge python3 and then used whereis python3 to find anything else that remains and i removed all of them. – Arash Kadkhodaei Aug 13 '18 at 6:13
2

Based on the information you've supplied, it's impossible to say what went wrong, or precisely what the problem is. You might consider simply re-installing your chosen OS to the SD card; in other words, just start from scratch. You'll likely spend far more time trying to "back out" or undo whatever it is you've done that's giving you those errors.

If you can recall the exact steps you followed when you purged all of your Python packages, we might be able to do better, but that will depend entirely on what you did. The only "magic do-over" is to re-install your OS.

Hope that helps.

  • I need files and packages that i installed... – Arash Kadkhodaei Aug 13 '18 at 6:16
  • @ArashKadkhodaei Write their names down and install them again. Make a back-up if necessary. – Mast Aug 13 '18 at 7:56
  • I will do the same if there is no other way. – Arash Kadkhodaei Aug 13 '18 at 8:41
  • @ArashKadkhodaei: You can re-install the files and packages you installed. If the files are unique, you'll need to copy them onto another storage medium (i.e. other than your SD card). Then restore after you're back to a manageable state. And do follow Ingo's advice wrt manual deletions... that is almost never a good idea. – Seamus Aug 13 '18 at 13:09
2

One possible answer is packages are corrupted or were not fully removed. As noted you are missing dependencies which is why you're getting those errors. In my opinion I would do a complete reinstall of python3 after you try removing packages again.

Try this:

sudo apt-get –purge remove python3.5-minimal
sudo apt-get –purge remove python3-minimal
sudo apt-get autoremove –purge

Then you can attempt to reinstall

  • This is what i get: You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: dh-python : Depends: python3:any (>= 3.3.2-2~) lsb-release : Depends: python3:any (>= 3.4~) E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). – Arash Kadkhodaei Aug 13 '18 at 6:15
  • @ArashKadkhodaei And have you tried running that, apt --fix-broken install? – Mast Aug 13 '18 at 7:56
  • I get the same error in question – Arash Kadkhodaei Aug 13 '18 at 8:40
  • I'm getting the same. Running --fix-broken spits out a series of errors: "string cannot be null bytes". I tried re-installing from the version in the apt-cache - same result. It's something else in a post-install script or something. – Scott Wood Apr 1 at 5:49
2

The mistake was that you have used whereis python3 to purge remaining files from python3. This was outside the package manager so it could not manage dependencies of purged files. The result is what you have. For the next time only use the package manager with apt, apt-get or dpkg (I prefer apt). This will avoid dependency problems.

You can try to reinstall the packages that have unmet dependencies. As far as I can see from your error message these are

dh-python : Depends: python3:any (>= 3.3.2-2~)
lsb-release : Depends: python3:any (>= 3.4~)

Reinstall these packages in the hope the package manager will also (re)install the packages they depend on:

rpi ~$ sudo apt --reinstall --ignore-missing install dh-python
rpi ~$ sudo apt --reinstall --ignore-missing install lsb-release
rpi ~$ sudo apt install python3
  • Yes that was a mistake. – Arash Kadkhodaei Aug 13 '18 at 10:29
  • Again Same error: The following packages have unmet dependencies: dh-python : Depends: python3:any (>= 3.3.2-2~) lsb-release : Depends: python3:any (>= 3.4~) E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). – Arash Kadkhodaei Aug 13 '18 at 10:30
  • This message comes with sudo apt install --reinstall dh-python? – Ingo Aug 13 '18 at 10:47
  • With all of them. – Arash Kadkhodaei Aug 13 '18 at 11:21
  • @ArashKadkhodaei I have updated my answer. Try apt install with additional option --ignore-missing. – Ingo Aug 13 '18 at 11:44

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.