Problems after trying to upgrade Python

I am still able to run Anaconda, but the Python installation is suffering some issues after accidentally creating a wrong symbolic link and then trying to upgrade Python version

The following additional packages will be installed:
apport apport-gtk aptdaemon python3-apport python3-apt python3-aptdaemon python3-aptdaemon.gtk3widgets                  python3-distupgrade python3-software-properties python3-update-manager ubuntu-drivers-common                            ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk unattended-upgrades update-manager-core update-notifier        update-notifier-common
Suggested packages:
x-terminal-emulator python3-launchpadlib python3-apt-dbg python-apt-doc python3-aptdaemon.pkcompat bsd-mailx            default-mta | mail-transport-agent needrestart
The following NEW packages will be installed:
apport apport-gtk aptdaemon python3-apport python3-apt python3-aptdaemon python3-aptdaemon.gtk3widgets                  python3-distupgrade python3-software-properties python3-update-manager ubuntu-release-upgrader-core                     ubuntu-release-upgrader-gtk unattended-upgrades update-manager-core update-notifier update-notifier-common            The following packages will be upgraded:                                                                                  ubuntu-drivers-common

Preparing to unpack .../00-python3-apt_1.6.5ubuntu0.5_amd64.deb ...
Unpacking python3-apt (1.6.5ubuntu0.5) ...
Preparing to unpack .../01-ubuntu-drivers-common_1%3a0.8.6.3~0.18.04.1_amd64.deb ...
File "/usr/bin/py3clean", line 4
SyntaxError: Non-ASCII character '\xc2' in file /usr/bin/py3clean on line 4, but no encoding declared;
see http://python.org/dev/peps/pep-0263/ for details
dpkg: error processing archive /tmp/apt-dpkg-install-UU4SRN/01-ubuntu-drivers-common_1%3a0.8.6.3~0.18.04.1_amd64.deb (--unpack):

new ubuntu-drivers-common package pre-removal script subprocess returned error exit status 1
File "/usr/bin/py3compile", line 4
SyntaxError: Non-ASCII character '\xc2' in file /usr/bin/py3compile on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
    
dpkg: error while cleaning up:
installed ubuntu-drivers-common package post-installation script subprocess returned error exit status 1

Errors were encountered while processing:
/tmp/apt-dpkg-install-UU4SRN/01-ubuntu-drivers-common_1%3a0.8.6.3~0.18.04.1_amd64.deb

Cannot run neither sudo dpkg --configure -a nor sudo apt-get install -f

Answer

Your post is a little thin on details (what do you exectly did? why including anaconda in the description? etc); however, manually upgrading the system-wide python installation is a bad idea, as many system utilities depends on the correct python version. I strongly advise you to revert your change and, if a newer python version is required, to build a python virtual environment.

That said, the only issue I can see is that a single package (01-ubuntu-drivers-common_1%3a0.8.6.3~0.18.04.1_amd64.deb) can not be installed, due to an unexpected char in the installation script. Are we sure it depends on the python upgrade? If so, why?

Please revert your python upgrade and try again.

Attribution
Source : Link , Question Author : Boris Mocialov , Answer Author : shodanshok

Leave a Comment