qwerty763
Posts: 2
Joined: Sat Mar 02, 2019 2:35 pm

Problem upgrading - broken Python installation

Sat Mar 02, 2019 2:42 pm

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!

robbes
Posts: 144
Joined: Sun Jan 20, 2013 7:11 pm
Location: Canada - off the west coast

Re: Problem upgrading - broken Python installation

Mon Mar 04, 2019 5:39 pm

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

qwerty763
Posts: 2
Joined: Sat Mar 02, 2019 2:35 pm

Re: Problem upgrading - broken Python installation

Mon Mar 04, 2019 6:49 pm

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 (?).

User avatar
DougieLawson
Posts: 36327
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Problem upgrading - broken Python installation

Mon Mar 04, 2019 11:51 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Python”