If I change `exec python3` in `/usr/bin/sage` to `exec "$SAGE_PYTHON"/bin/python3` (i.e. apply the changes in the linked commit), sage does load up successfully even if a virtual environment is active (i.e. if `python3` points somewhere other than `/usr/bin/python3`). IPython does still issue a warning about the active venv, but sage is able to successfully start. Not sure if there is any interest in a backport here, or even if this package is under active maintenance in Ubuntu, but thought I'd share some more information about the problem upstream.
I should also note that on 22.04 (sage 9.5), sage does not start when a venv is active, although the error report is substantially longer and it appears to be a separate issue.
Looking at this again, I believe this bug may have been fixed (or at least mitigated) in Sage 9.1, which introduced some changes to the `sage` entrypoint around the `exec` commands I identified in my original report. More specifically the changes introduced by this commit: https:/ /github. com/sagemath/ sage/commit/ 248c13b542b1252 1bd91d6648bd622 0fb7593a26 (tied to this ticket on the sagemath tracker: https:/ /trac.sagemath. org/ticket/ 29627)
If I change `exec python3` in `/usr/bin/sage` to `exec "$SAGE_ PYTHON" /bin/python3` (i.e. apply the changes in the linked commit), sage does load up successfully even if a virtual environment is active (i.e. if `python3` points somewhere other than `/usr/bin/ python3` ). IPython does still issue a warning about the active venv, but sage is able to successfully start. Not sure if there is any interest in a backport here, or even if this package is under active maintenance in Ubuntu, but thought I'd share some more information about the problem upstream.
I should also note that on 22.04 (sage 9.5), sage does not start when a venv is active, although the error report is substantially longer and it appears to be a separate issue.