0

Raspbian Stretch OS

I tried sudo apt-get update and then upgrade

There is no issue with update but upgrade or while installing any package for instance sudo apt-get install tightvncserver gives the following error :

dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: /var/cache/apt/archives/python-phatbeat_0.1.1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

The first time I encountered it was while installing npm:

dpkg: dependency problems prevent configuration of node-gyp: node-gyp depends on gyp (>= 0.1+20150913git1f374df9); however: Package gyp is not configured yet.

When I tried again installation stuck at:

57% [Connecting to raspbian.raspberrypi.org (2a00:1098:0:80:1000:75:0:3)]^C

And then on every install or upgrade I see dpkg everywhere.

I tried :

  • Uninstalling perl sudo apt-get remove perl (Same error occurred) Not able to install it again
  • As suggested here sudo rm /etc/apt/sources.list but sudo software-properties-gtk command not found error.
  • sudo apt-get autoremove && sudo apt-get autoclean resulted in Error:

E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

  • sudo dpkg --configure -a gives :

    dpkg: error processing package python-phatbeat (--configure): package is in a very bad inconsistent state; you should reinstall it before attempting configuration Processing triggers for hicolor-icon-theme (0.15-1) ... Errors were encountered while processing: gyp python-phatbeat

  • sudo apt --fix-broken install resulted in Error:

    perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_GB.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_GB.UTF-8"). locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory (Reading database ... 109991 files and directories currently installed.) Preparing to unpack .../python-phatbeat_0.1.1_all.deb ... /var/lib/dpkg/info/python-phatbeat.prerm: 6: /var/lib/dpkg/info/python-phatbeat.prerm: pyclean: not found dpkg: warning: subprocess old pre-removal script returned error exit status 127 dpkg: trying script from the new package instead ... /var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: pyclean: not found dpkg: error processing archive /var/cache/apt/archives/python-phatbeat_0.1.1_all.deb (--unpack): subprocess new pre-removal script returned error exit status 127 /var/lib/dpkg/info/python-phatbeat.postinst: 6: /var/lib/dpkg/info/python-phatbeat.postinst: pycompile: not found dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: /var/cache/apt/archives/python-phatbeat_0.1.1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

*same errors.

In response to @Ingo :

It all started after I tried to install node and npm then uninstalled it. (sudo apt-get install node then npm and removed them sudo apt-get remove nodejs + sudo apt-get remove npm)

As I removed the sources.list file and couldn't generate again. I created with the content you provided and followed the procedure:

Result: (Also, fixed the locale error)

pi@raspberrypi:~ $ sudo apt full-upgrade Reading package lists... Done Building dependency tree
Reading state information... Done Calculating upgrade... Done The following packages were automatically installed and are no longer required: fakeroot g++ g++-6 libfakeroot read-edid Use 'sudo apt autoremove' to remove them. The following packages will be upgraded: python-phatbeat 1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 8 not fully installed or removed. Need to get 0 B/5,646 B of archives. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Y Reading changelogs... Done (Reading database ... 109860 files and directories currently installed.) Preparing to unpack .../python-phatbeat_0.1.1_all.deb ... /var/lib/dpkg/info/python-phatbeat.prerm: 6: /var/lib/dpkg/info/python-phatbeat.prerm: pyclean: not found dpkg: warning: subprocess old pre-removal script returned error exit status 127 dpkg: trying script from the new package instead ... /var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: pyclean: not found dpkg: error processing archive /var/cache/apt/archives/python-phatbeat_0.1.1_all.deb (--unpack): subprocess new pre-removal script returned error exit status 127 /var/lib/dpkg/info/python-phatbeat.postinst: 6: /var/lib/dpkg/info/python-phatbeat.postinst: pycompile: not found dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: /var/cache/apt/archives/python-phatbeat_0.1.1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

How to reinstall python-phatbeat and configure gyp and gconf2?

On pi@raspberrypi:~ $ sudo dpkg --audit | more:

The following packages are in a mess due to serious problems during installation. They must be reinstalled for them (and any packages that depend on them) to function properly: python-phatbeat Python library for the Pimoroni pHAT BEAT.

The following packages are only half configured, probably due to problems configuring them the first time. The configuration should be retried using dpkg --configure or the configure menu option in dselect: gconf2 GNOME configuration database system (support tools) gyp Cross-platform build script generator

I tried sudo dpkg --configure gconf2:

Setting up gconf2 (3.2.6-4) ... /var/lib/dpkg/info/gconf2.postinst: 45: /var/lib/dpkg/info/gconf2.postinst: gconf-schemas: not found dpkg: error processing package gconf2 (--configure): subprocess installed post-installation script returned error exit status 127 Errors were encountered while processing: gconf2

1

Seems you have really mixed up your packet manager. I suggest to reset its installation lists by editing sources.list and raspi.list. By default it looks like this:

rpi ~$ cat /etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

rpi ~$ cat /etc/apt/sources.list.d/raspi.list
deb http://archive.raspberrypi.org/debian/ stretch main ui
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ stretch main ui

In both files comment the first line with a # and any additional repository if present. Then do:

rpi ~$ sudo apt update

This will clear the lists from apt in /var/lib/apt/lists/. It it nearly then same by doing sudo rm /var/lib/apt/lists/* and sudo rm /var/lib/apt/lists/partial/* but under control of the packet manager. Then uncomment the lines you have commented and do:

rpi ~$ sudo apt update
rpi ~$ sudo apt full-upgrade

Update:
After this we have a defined state but there is still an error message telling python-phatbeat is incomplete. The goal now is to purge everything not needed in the hope we also purge broken packets and dependencies. On this clean installation we can then install again what we want, e.g. python-phatbeat. So try to purge it with:

rpi ~$ sudo apt purge python-phatbeat

If it works, maybe with warnings, you should clean up other installations:

rpi ~$ sudo apt --simulate purge fakeroot
rpi ~$ sudo apt --simulate purge g++
rpi ~$ sudo apt --simulate purge g++-6
rpi ~$ sudo apt --simulate purge libfakeroot
rpi ~$ sudo apt --simulate purge read-edid

Do it step by step with single commands so you can see what will happen with the specific packet. I have listed the commands with the option --simulate. This will not really purge the packet but shows what will happen. If you are sure that will go simply omit --simulate.

After this there may be orphaned libraries we do not need. To find them use deborphan:

rpi ~$ sudo apt install deborphan
rpi ~$ deborphan

It will show you orphaned libraries. You can purge them all with:

rpi ~$ sudo apt purge $(deborphan)

Do it more than one time until there are no more orphaned libraries. But now we have still configuration files from the purged packets because dpkg do not purge them by default for updates. If they are misconfigured it may be possible they are used again on reinstalled packets. To show them:

rpi ~$ dpkg --get-selections | grep -vw install | cut -f1

and to purge them:

rpi ~$ sudo apt purge $(dpkg --get-selections | grep -vw install | cut -f1)

Reboot.

Then reinstall and install:

rpi ~$ sudo apt --reinstall install gconf2
rpi ~$ sudo apt --reinstall install gyp
rpi ~$ sudo apt install python-phatbeat

This is in general what I do to clean up broken installations. It must be taken care with purging orphaned libraries. I had found situations where I was told they are orphaned but still needed by packets due to bad configured packets. But that is quite rarely.

  • sudo apt update works fine. Getting the same error on sudo apt full-upgrade : updated the question with the results. – Ankit Dalal Jun 25 '18 at 7:09
  • @AnkitDalal I have updated my answer how I would clean up your installation if it works as expected. – Ingo Jun 25 '18 at 22:36
0

In my case it was localization problem, so try to set your localization by

sudo raspi-config

Then reboot. It may work fine.

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.