https://github.com/pypa/pipx
Certain tools you may wish to use throughout your virtual environments.
One way to achieve this is to install the package 'globally', ie. not in a virtual env.
However more tools - more risk of dependency issues.
This is where pipx is used. It keeps tools in their own venvs, but allows you to use the tool as if were installed globally.
First need to remediate existing global packages.
$ pip freeze
$ pip uninstall ansible
Found existing installation: ansible 2.9.6
Can't uninstall 'ansible'. No files were found to uninstall.
ansible - probably installed with apt?
$ pip uninstall black
works fine. was installed to ~/.local/lib/python3.8/site-packages/
pipx installation - do not run this in the virtual environment
python3 -m pip install --upgrade pip
python3 -m pip install --user pipx
python3 -m pipx ensurepath
usage
pipx install X
pipx list
global packages uninstalled and not reinstalleed
pandas==1.2.2
global uninstalled
ansible==2.9.6 - didn't work
black==22.3.0
cookiecutter==2.1.1
great-expectations==0.13.10
pipdeptree==2.2.1
pylint==2.7.2
global packages I have installed with pipx
(NB: have not pinned version when installing with pipx)
pipx install ansible
pipx install black
pipx install cookiecutter
pipx install great-expectations
pipx install pipdeptree
pipx install pylint
pipx install behave
pipx install flake8
pipx install flake8-bandit
pipx install pydocstyle --include-deps
pipx install flake8-bandit --include-deps
pipx install sphinx
If you were to run where x now, it would still show as ~/local/bin/ but the executable is now a symlink to a path in ~/.local/pipx/venvs/x/bin/x
Use flake 8 in vscode (https://pycon.switowski.com/02-packages/pipx/): $ which flake8 /Users/YOUR_USERNAME/.local/bin/flake8
Tell VS Code to use that binary by setting the following value in settings.json file: "python.linting.flake8Path": "/Users/YOUR_USERNAME/.local/bin/flake8"