Pip installs packages successfully, but executables not found from command line
Often, the issue arises because the installation path for the executables of pip installed packages isn’t in your PATH environment variable. A quick fix:
If you're working on a Windows system:
(Change PythonXX
to match your Python version)
For Unix-like systems(Linux/macOS):
(Load the changes with source ~/.bashrc
or restart the terminal)
Remember to replace the aforementioned paths with the ones corresponding to your Python installation.
Deciphering PATH variable
The PATH is a list of directories that your operating system searches through when looking for executable files. When pip installs a package that includes executables, they might be stored in a directory missing from your PATH. Therefore, your system cannot access these executables from the command line.
Inspect your current PATH with:
Make sure that the directory where pip places the scripts (usually ~/.local/bin
on Unix-like systems) is part of your PATH, if not you need to include it.
Setting PATH the right way
To ensure your changes persist across sessions, add the correct path to your shell configuration file (.bashrc or .bash_profile):
For systems with multiple Python versions, make sure you're adding the specific version's bin
directory to your PATH:
Exploring missing executables causes
If your PATH is correctly set and you're still running into issues, several different culprits might be to blame:
- Multiple Python installations: Double-check you're changing the PATH for the right version. Run
which python
and check. - Custom Python userbase: For installations done using
pip install --user
, check your user installation directory with Python'ssite
module. - Non-default install locations: The location of the executable might not be included in your PATH.
Other ways to fix this
Validate with the ‘which’ command
Use the which
command to locate installed executables:
Check out Python’s user directory
If you're using the --user
flag with pip, you can find out the user install directory with:
Include /bin
for Unix-like systems or \Scripts
for Windows when updating PATH.
Reboot your shell
It's essential to restart your terminal or load your updated profile for changes in the PATH to take effect:
Make PATH adjustments dynamic
If you frequently switch between different Python environments, consider using scripts or tools like pyenv that adjust the PATH on-the-fly.
Was this article helpful?