Invoking "python" brings inappropriate response from command-not-found when python3 installed

Bug #1863532 reported by Neil McPhail
30
This bug affects 7 people
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)
High
Dimitri John Ledkov
Focal
High
Dimitri John Ledkov
python3-defaults (Ubuntu)
Undecided
Unassigned
Focal
Undecided
Unassigned

Bug Description

Ubuntu Mate 20.04 development release, upgraded from 19.10. I don't have python 2.7 installed, but have python 3 installed as per default.

Please see ascii-cast at https://asciinema.org/a/SZR20NHz2FN6N6O1hj2Mqmnv8 .

Running `python` brings up text from command-not-found which suggests installing `python3` as a solution to the missing command. `python3` is already installed, is a later version than the one indicated by command-not-found and does not supply a binary or symlink named `python`.

$ apt policy python
python:
  Installed: (none)
  Candidate: (none)
  Version table:
     2.7.17-1 -1
        100 /var/lib/dpkg/status
$ apt policy python3
python3:
  Installed: 3.8.0-3
  Candidate: 3.8.0-3
  Version table:
 *** 3.8.0-3 500
        500 http://gb.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
$ apt policy command-not-found
command-not-found:
  Installed: 19.10.0
  Candidate: 19.10.0
  Version table:
 *** 19.10.0 500
        500 http://gb.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu focal/main i386 Packages
        100 /var/lib/dpkg/status

I don't know whether this is a bug in python3 or command-not-found (the latter of which doesn't seem to have been updated for 20.04 yet). i don't know if it is intentional that `python3` will not provide a binary or symlink named `python`. if that is the case, the output of `command-not-found` should be updated to reflect that.

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: python3 3.8.0-3
ProcVersionSignature: Ubuntu 5.4.0-14.17-generic 5.4.18
Uname: Linux 5.4.0-14-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.11-0ubuntu16
Architecture: amd64
CurrentDesktop: MATE
Date: Mon Feb 17 01:35:16 2020
InstallationDate: Installed on 2019-10-11 (128 days ago)
InstallationMedia: Ubuntu-MATE 19.10 "Eoan Ermine" - Beta amd64 (20190926.2)
SourcePackage: python3-defaults
UpgradeStatus: Upgraded to focal on 2020-02-07 (10 days ago)

Revision history for this message
Neil McPhail (njmcphail) wrote :
Revision history for this message
Neil McPhail (njmcphail) wrote :

$ apt policy python3-commandnotfound
python3-commandnotfound:
  Installed: 19.10.0
  Candidate: 19.10.0
  Version table:
 *** 19.10.0 500
        500 http://gb.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu focal/main i386 Packages
        100 /var/lib/dpkg/status

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in command-not-found (Ubuntu):
status: New → Confirmed
Changed in python3-defaults (Ubuntu):
status: New → Confirmed
tags: added: champagne
Revision history for this message
Tony Travis (ajtravis) wrote :

Confirming this bug: "python3" installed, but "python" command not found after I upgraded my Ubuntu-MATE 18.04 to 20.04. I realise that Python 2 is being deprecated in 20.04, but there should be a default "python" command, so I added a Debian alternative:

update-alternatives --install /usr/bin/python python-interpreter /usr/bin/python3 90

tags: removed: champagne
Revision history for this message
Steve Langasek (vorlon) wrote :

The solution for this will be for us to provide a python-is-python3 package, not installed by default, which command-not-found will then offer.

This will NOT be managed as an alternative.

Changed in python3-defaults (Ubuntu Focal):
status: Confirmed → Triaged
Changed in command-not-found (Ubuntu Focal):
status: Confirmed → Triaged
Revision history for this message
Brian Murray (brian-murray) wrote :

The asciicinema stuff has disappeared but I presume this is the output:

 $ python

Command 'python' not found, but can be installed with:

sudo apt install python3 # version 3.7.5-1ubuntu1, or
sudo apt install python # version 2.7.17-1
sudo apt install python-minimal # version 2.7.17-1

You also have python3 installed, you can run 'python3' instead.

Revision history for this message
Neil McPhail (njmcphail) wrote :

Indeed. It offers python3 version 3.7.5-1ubuntu1 as a solution which is not appropriate as python3 version 3.8.0-3 is already installed and does not provide a `python` command.

The python-is-python3 solution sounds like a sensible way forward. There be dragons, I suspect.

Revision history for this message
Bill (franksmcb) (franksmcb) wrote :

Using 20.04 current build still see:

$ python

Command 'python' not found, but can be installed with:

If I run sudo apt install python

Package python is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python2-minimal:i386 python2:i386 python2-minimal python2 2to3

E: Package 'python' has no installation candidate

This has an effect on an upgrade to 20.04 of uninstalling any package that depends on "python" for example slack-desktop.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Expected behaviour is:

$ python

Command 'python' not found, did you mean:

  command 'python3' from deb python3 (3.8.2-0ubuntu1)

Try: sudo apt install <deb name>

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

$ python
Command 'python' not found, did you mean:

  command 'python3' from deb python3

Is the new behaviour

Changed in python3-defaults (Ubuntu Focal):
status: Triaged → Invalid
Changed in command-not-found (Ubuntu Focal):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package command-not-found - 20.04.0

---------------
command-not-found (20.04.0) focal; urgency=medium

  * Special case python -> python3, using existing translated strings. LP:
    #1306682, LP: #1863532

 -- Dimitri John Ledkov <email address hidden> Thu, 12 Mar 2020 13:10:32 +0000

Changed in command-not-found (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote :

Dimitri, this is contrary to the plan of record. Please revert.

Changed in command-not-found (Ubuntu Focal):
status: Fix Released → Invalid
Changed in python3-defaults (Ubuntu Focal):
status: Invalid → Triaged
Changed in command-not-found (Ubuntu Focal):
status: Invalid → Triaged
importance: Undecided → High
Revision history for this message
Steve Langasek (vorlon) wrote :

The expected behavior is that typing 'python' recommends installing the python3-is-python package, /which needs to be added to the archive/.

Revision history for this message
Steve Langasek (vorlon) wrote :

Correction: 'python-is-python3'

Changed in command-not-found (Ubuntu Focal):
assignee: nobody → Dimitri John Ledkov (xnox)
tags: added: id-5e4eb982f81e3673a2d90aa6
Revision history for this message
Steve Langasek (vorlon) wrote :

Current behavior on focal:

$ python

Command 'python' not found, did you mean:

  command 'python3' from deb python3
  command 'python ' from deb python-is-python3

$

There's an extra space in the name 'python ', can we get this fixed?

Revision history for this message
Matthias Klose (doko) wrote :

the current aligned output is more readable. So either leave it this way, or keep it aligned while removing the space within the quotes.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

@vorlon

I've played with output about a dozen times. All other output from command not found is always aligned. It looks very odd when the output looks like a Christmas tree, without breaking translations.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

maybe we can specify format padding around '%s'

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers