apt-get install packages introduces lots of python errors on Ubuntu

Question:

apt-get install -y my_package
Everything works until
Setting up my_package...
And lots of python errors like the below appeared:

Compiling ./ext/python3.9/lib/python3.9/site-packages/setuptools/installer.py ...
  File "./ext/python3.9/lib/python3.9/site-packages/setuptools/installer.py", line 77
    raise DistutilsError(str(e)) from e
                                    ^
SyntaxError: invalid syntax

I suspect it has something to do with python versions

ls -la /usr/bin/python
/usr/bin/python -> python2.7
Asked By: instant501

||

Answers:

Based on the symptoms, sounds like a packaging bug.

It looks like the package’s scripts are expecting python to be Python 3 and is thus inadvertently running Python 2’s compileall against Python 3 files.

Answered By: AKX
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.