script: python does not use Python 3 on Linux and macOS

script: pythonis returning an indeterminant Python depending on the OS even when I install Python 3.8.0 on Linux, macOS, and Windows.  Could the script run in the installed Python instead of the system Python?  Or could we please have script: python3 or some other technique to provide consistancy across OSes?  Currently it is {Linux: Python 2.7.15+, macOS: Python 2.7.16, Windows: Python 3.6.8}.  There are 56 days until Python 2 end of life.

name: python_version
on: [push, pull_request]
    runs-on: ${{ matrix.os }}
      max-parallel: 3
        os: [macOS-latest, ubuntu-latest, windows-latest]
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
          python-version: 3.x
      - shell: python
        run: |
          import sys
          print("Python {}.{}.{}".format(*sys.version_info))P  

Hi cclauss,

This issue is already tracked in the ticket below:

We can use shell: bash, pwsh…etc directly for python command.

For ‘shell: python’, as a workaround, we can manually change the default python version by an extra step.

Ubuntu as example:

      - name: change default
        shell: bash
        run: |
          sudo update-alternatives --install /usr/bin/python python ${pythonLocation}/bin/python3.8 10
      - shell: python
        run: |
          import sys

the output displays the version has been changed to 3.8.0 for ubuntu, hope it helps.

The following used to work but no longer does:

sudo update-alternatives --install /usr/bin/python python ${pythonLocation}/bin/python3.8 10

This may depend on your OS. In ‘ubuntu-latest’ python3.6 is the latest installation.
Maybe just using the generic python3 could do the trick rather than specifying a particular version.

sudo update-alternatives --install /usr/bin/python python ${pythonLocation}/bin/python3 10