Sage cannot be launched if `python3` does not point to system interpreter
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sagemath (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
## Expected behavior:
Running `sage` after installing the `sagemath` command starts Sage, even if `python3` resolves somewhere other than `/usr/bin/python3` (examples of when it doesn't: virtual environments, use of the conda package manager, pyenv)
## Actual behavior:
```
$ sage
Traceback (most recent call last):
File "/usr/share/
from sage.misc.banner import banner
ModuleNotFoundE
```
## Reproduction:
```
$ sudo apt install sagemath
...
$ which python3
/usr/bin/python3
$ sage
┌──────
│ SageMath version 9.0, Release Date: 2020-01-01 │
│ Using Python 3.8.10. Type "help()" for help. │
└──────
sage: 1 + 1
2
sage:
Exiting Sage (CPU time 0m0.14s, Wall time 0m27.42s).
$ python3 -m venv --copies /tmp/testvenv # note: --copies is necessary for full isolation
$ source activate /tmp/testvenv/
$ which python3
/tmp/testvenv/
$ sage
Traceback (most recent call last):
File "/usr/share/
from sage.misc.banner import banner
ModuleNotFoundE
```
As a workaround for anybody else who stumbles into this, you can still invoke sage as: `/usr/bin/python3 /usr/share/
## Additional information
There are a few layers of indirection at work in this bug, but at the end of the day, this happens because of an `exec python3` embedded in the part of the `sage` shell script responsible for launching Python. Upstream reference: https:/
If I'm not mistaken, these lines should always point to /usr/bin/python3 for the Ubuntu package to avoid this flaw. Note that there are other executables (ipython in particular) which may be appropriate to locate against the system as well. The package maintainer(s) probably know how to fix this better than I do, but I can confirm that replacing `exec python3` with `exec /usr/bin/python3` in these two locations does appear to resolve the problem.
## Boilerplate information:
1) system info
$ lsb_release -rd
Description: Ubuntu 20.04.3 LTS
Release: 20.04
2) package info
$ apt-cache policy sagemath
sagemath:
Installed: 9.0-1ubuntu4
Candidate: 9.0-1ubuntu4
Version table:
*** 9.0-1ubuntu4 500
500 http://
100 /var/lib/
Status changed to 'Confirmed' because the bug affects multiple users.