Skip to content

Modify mssql-cli bash wrapper to look for and prefer python3 #518

Description

@JPvRiel

On Ubuntu 20.04, the following install via pip does not work:

pip3 install --user mssqlcli

There are instructions to use a deb package for 18.04, but that's not an option. Related issues: #505, #482

In the bash wrapper to run this, I noticed python, and not python3, is assumed as the executable at

python -m mssqlcli.main "$@"

Some distributions (at least Debian/Ubuntu) facilitate the transition from python2 to python3 by having python point to python2 and python3 be a separate binary.

Instead of:

python -m mssqlcli.main "$@"

The following way of using command to check and match might help:

python_exe=$(command -v python3 || command -v python)
$python_exe -m mssqlcli.main "$@"

Then absolute path should be nicely resolved, e.g. /usr/bin/python3 for systems that have a binary found in the PATH.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions