-1

I'm using OSX Monterey, and whenever I install a python package that is supposed to provide a commandline tool, say pipreqs for example I can never run it as suggested like this:

$ pipreqs

Instead I am forced to run it as a module like this:

$ python -m pipreqs

And this goes for all of these python modules which are supposed to provide a command I can run.

I can't even add them to my path cos I have no idea where these binaries are bieng installed, or even if they are being installed.

pnadeau
  • 427
  • 5
  • 8
  • 1
    If you say "whenever I install a python package", also say _how_ you're installing packages. E.g. by showing the actual CLI command(s) you use. Having said that: you're showing you use the `python` command: that's the now-_long_-dead python 2.7, so the first thing to do is almost certainly to _stop using that_ and use the `python3` command instead, with the associated `pip3`. – Mike 'Pomax' Kamermans Aug 12 '23 at 00:31

1 Answers1

0

pip* placed aliases into a directory that is not on your path. Everything about your installation is ambiguous. You must remove the ambiguity by calling modules from the Python environments in which they have been installed, or you must include those directories on your path.

For example, a commonly ignored Python warning states: WARNING: The scripts pip, pip3 and pip3.10 are installed in '/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/bin' which is not on PATH. Consider adding this directory to PATH

This means you need to adjust the PATH if you expect to access the tools directly from your shell:

export PATH=$PATH:/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/bin

The problem with this comes when you realize your system has multiple concurrent Python environments. The solution is to always call Python modules from the desired Python environment, for example:

/full/path/to/python3 -m pip install pipreqs

and then directly calling:

/full/path/to/python3 -m pipreqs .
Richard Barber
  • 5,257
  • 2
  • 15
  • 26
  • Lets just say that, I'm using the built in python env (I'm not using homebrew) and I'd rather not have to use `-m` – pnadeau Aug 12 '23 at 12:16
  • 1
    Got it, they were ending up in a base anaconda env that I forgot about. After adjusting my PATH everything is working fine. – pnadeau Aug 12 '23 at 12:30