mssql-cli icon indicating copy to clipboard operation
mssql-cli copied to clipboard

Installation via pipx doesn't work

Open akrabat opened this issue 5 years ago • 2 comments

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/[email protected]/bin/python3.8: Error while finding module specification for 'mssqlcli.main' (ModuleNotFoundError: No module named 'mssqlcli')

akrabat avatar Oct 13 '20 11:10 akrabat

As far as I understand:

  • pipx recommends that packages useentry_points in their setup.py.
  • Yet pipx has some support for scripts, namely it symlinks them from the app's virtualenv to ~/.local/bin
  • mssql-cli uses their own shell scripts instead of entry_points, because they need to set PYTHONIOENCODING: the switch to entry_points contributed by @cs01 in 2018 was later reverted in September 2019 https://github.com/dbcli/mssql-cli/pull/299

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 avatar Oct 17 '20 07:10 nickolay

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 "$@")

nickolay avatar Oct 17 '20 07:10 nickolay