Page 1 of 1

Problem upgrading - broken Python installation

Posted: Sat Mar 02, 2019 2:42 pm
by qwerty763
Hi everyone,

I have this weird problem when upgrading/installing any packages on one of my Pis:

Code: Select all

dpkg: trying script from the new package instead ...
  File "/usr/bin/pyclean", line 82
    if options.verbose or environ.get('PYCLEAN_DEBUG') == '1':
                        ^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-ldb_2%3a1.1.27-1+deb9u1_armhf.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
  File "/usr/bin/pycompile", line 212
    if options.verbose or environ.get('PYCOMPILE_DEBUG') == '1':
                        ^
SyntaxError: invalid syntax
It seems that this is not a dpkg problem, but that for some reason the Python 2.7 installation is shot, as even the interactive interpreter complains about invalid syntax after entering only this line (which works on the same machine in Python 3):

Code: Select all

 if a or b:
Any ideas how to fix this without reinstalling the whole thing?

Thanks!

Re: Problem upgrading - broken Python installation

Posted: Mon Mar 04, 2019 5:39 pm
by robbes
You could try running

Code: Select all

dpkg --audit python
and

Code: Select all

dpkg --verify python
for suggestions, before doing --remove or --purge and reinstalling

Re: Problem upgrading - broken Python installation

Posted: Mon Mar 04, 2019 6:49 pm
by qwerty763
Thanks for the response,
unfortunately neither of those commands produce any output at all.

I'm afraid that uninstalling and reinstalling just python will run into the same problem as upgrading, since dpkg itself is running some python scripts in the process (?).

Re: Problem upgrading - broken Python installation

Posted: Mon Mar 04, 2019 11:51 pm
by DougieLawson
The simplest resolution needs a new SDCard, a new copy of Raspbian Stretch and a USB SDCard reader (so you can copy important things from your broken system).

Start afresh you are wasting your time trying to fix this disaster area.