dbcli / mssql-cli

A command-line client for SQL Server with auto-completion and syntax highlighting
BSD 3-Clause "New" or "Revised" License
1.35k stars 192 forks source link

Installation via pipx doesn't work #496

Open akrabat opened 3 years ago

akrabat commented 3 years ago

A merged PR implies that pipx can be used, but it doesn't work for me.

$ pipx install mssql-cli
  installed package mssql-cli 1.0.0, Python 3.9.0
  These apps are now globally available
    - mssql-cli
    - mssql-cli.bat
done! ✨ 🌟 ✨
$ mssql-cli
/usr/local/opt/python@3.8/bin/python3.8: Error while finding module specification for 'mssqlcli.main' (ModuleNotFoundError: No module named 'mssqlcli')
nickolay commented 3 years ago

As far as I understand:

Seems like it's a pipx issue, which should at least document the solution for people who want to use non-python scripts that run python -m and expect their module to be installed. Or maybe install a wrapper executable to .local/bin, that activates the correct virtualenv and runs the original script afterwards.

Note that .py scripts like https://github.com/aws/aws-cli/blob/c1c11afa6b4a76e3790b618ed746feeb25f70446/bin/aws#L1 on nix work auto-magically because something rewrites their shebang to point to the python executable from the app's virtualenv.

nickolay commented 3 years ago

Oh, the workaround is to change the last line of ~/.local/bin/mssql-cli to point to the virtualenv's python (on my system it's ~/.local/pipx/venvs/mssql-cli/Scripts/python -m mssqlcli.main "$@")