Find pip package executable on mac

When you install a pip package it might happen that you cannot find the executable for the package.

Let's take for example the Commit helper package

Run the following command to install it (or skip this step if you have a different package to find):

pip install git+https://gitlab.com/marius-rizac/commit-helper.git

What you need to do to find it, first you have to check if the package was installed and is available in your pip packages:

pip3 list

You should see commit in the packages list.

Let's run the show command for the commit package to see where it was installed:

pip3 show commit

The output will be like this:

Name: commit
Version: 0.1.1
Summary: Append ticket number in commit message
Home-page: UNKNOWN
Author: Author Name
Author-email: test@example.com
License: UNKNOWN
Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
Requires:
Required-by:

Go to the location directory

cd /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages

When you run ls -la command in this directory you should see the directory name of the package. In my case is:

...
commit-0.1.1-py3.7.egg-info
...

Go inside your package directory

cd commit-0.1.1-py3.7.egg-info

In this directory you'll have the following files:

PKG-INFO
SOURCES.txt
dependency_links.txt
entry_points.txt
installed-files.txt
top_level.txt

If you check the content of the installed-files.txt file, you'll see where the executable file was installed:

cat installed-files.txt

The output will be:

../../../../bin/commit
../../../../bin/commit.py
PKG-INFO
SOURCES.txt
dependency_links.txt
entry_points.txt
top_level.txt

From the first line, copy the path, except the filename and go into that directory

cd ../../../../bin/

This is the bin directory for the installed packages on pip3.

Now, you have to copy the current path and add it to your .bashrc file.

Run pwd command to get the current location:

pwd

And copy the directory and add it to your .bashrc file:

PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH"

Open a new terminal and now your newly installed pip package will be available in your terminal

This was a good way to find the location if you don't know it. I would suggest to try the directory location from above first and if is not there, then follow the instructions to find it.