0

I am having an issues updating my raspbian operating system. After running sudo apt-get update && sudo apt-get upgrade -y I receive the following error messages:

Hit:1 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Get:2 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
Fetched 25.4 kB in 10s (2,331 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  libavformat57 piwiz python-gpiozero python3-gpiozero python3-thonny wolfram-engine
The following packages will be upgraded:
  python-automationhat python-piglow python-smbus python3-smbus
4 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
36 not fully installed or removed.
Need to get 19.5 kB/59.5 kB of archives.
After this operation, 46.1 kB disk space will be freed.
Get:1 http://mirrors.switch.ca/raspbian/raspbian stretch/main armhf python-smbus armhf 3.1.2-3 [9,740 B]
Get:2 http://mirrors.switch.ca/raspbian/raspbian stretch/main armhf python3-smbus armhf 3.1.2-3 [9,774 B]
Fetched 19.5 kB in 1s (19.1 kB/s)
apt-listchanges: Reading changelogs...
(Reading database ... 121685 files and directories currently installed.)
Preparing to unpack .../python-automationhat_0.2.0_all.deb ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-automationhat_0.2.0_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python-piglow_1.2.5_all.deb ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
  File "/usr/bin/pyclean", line 63
    except (IOError, OSError), e:
                             ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-piglow_1.2.5_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Preparing to unpack .../python-smbus_3.1.2-3_armhf.deb ...
Unpacking python-smbus:armhf (3.1.2-3) over (3.1.1+svn-2) ...
Preparing to unpack .../python3-smbus_3.1.2-3_armhf.deb ...
Unpacking python3-smbus:armhf (3.1.2-3) over (3.1.1+svn-2) ...
Errors were encountered while processing:
 /var/cache/apt/archives/python-automationhat_0.2.0_all.deb
 /var/cache/apt/archives/python-piglow_1.2.5_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

It seems that python-automationhat does not want to cooperate and either purge from the system or update properly. I've tried this:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/python-automationhat_0.2.0_all.deb

And this:

sudo apt remove python-automationhat

I've also tried installing the missing module with:

python pip install ConfigParser

The dpkg -i --force-overwrite and sudo apt remove both come back with errors about having to reinstall the package before continuing, I've also tried that and it still does not work.

Current Raspbian version:

Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.11 (stretch)
Release:        9.11
Codename:       stretch

Python version: Python 3.5.3

0

2 Answers 2

1

Seems you have done things disordered that may have done it worse. Lets try to do it step by step. First don't chain commands if you have trouble so you can see what command gives what messages:

rpi ~$ sudo apt update
rpi ~$ sudo apt full-upgrade   # yes, not only an upgrade

It's likely that you still get the error. Then you should reinitialize the package list. If it doesn't help you should follow the error messages about having to reinstall the package before continuing. You told that you have done it but don't show how. Use this command:

rpi ~$ sudo apt install --reinstall python-automationhat
rpi ~$ sudo apt full-upgrade

By the way, this is for python2. Because you use python3, you do not need it. Then you mentioned python pip install ConfigParser. It is unclear why do you do that. Beside that it is also for python2 and useless for you, you should not use pip3 if possible (never use pip). We have seen many trouble with it because it doesn't fit optimal into Raspbian and mostly you have to adapt it. I only have the buster repository available and there I find

rpi ~$  apt list *configparser
Listing... Done
cl-py-configparser/stable 20170830-1 all
python-configparser/stable 3.5.0b2-1 all

I suppose you will find it also in the stretch repository. You should use this package because it fit best into the Raspbian operating system.

In general you should take more care what python version do you use and install.

0

I had both Python 2.X and Python 3.X installed on the same RaspberryPi (/usr/bin/python was pointing to Python 3.X) and faced a similar problem during apt-get upgrade.

I was able to solve the problem by

  1. Linking /usr/bin/python to Python 2.x's executable
  2. Executing apt-get upgrade
  3. Linking /usr/bin/python back to Python 3.x's executable

I suggest installing python 2.7 and executing apt-get upgrade again.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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