How to Resolve Python Pip "WARNING: The script ... is installed in ... which is not on PATH"
When installing Python packages using pip
, you might encounter a warning message similar to: WARNING: The script <script_name>.exe is installed in 'C:\path\to\Scripts' which is not on PATH
(Windows) or WARNING: The script <script_name> is installed in '/path/to/bin' which is not on PATH
(Linux/macOS). This indicates that while the package was installed successfully, the command-line scripts included with it cannot be run directly from your terminal because their location isn't listed in your system's PATH
environment variable.
This guide explains how to fix this by adding the relevant directory to your system's PATH on both Windows and Unix-like systems (Linux/macOS).
Understanding the "not on PATH" Warning
The PATH
environment variable is a list of directories that your operating system searches through when you type a command in the terminal without specifying its full location. When pip
installs a package that includes executable scripts (like command-line tools), it places these scripts in a specific directory (often a Scripts
or bin
folder within your Python installation or virtual environment).
If this directory isn't listed in your PATH
, you can only run those scripts by typing their full path (e.g., C:\Python310\Scripts\script.exe
or /home/user/.local/bin/script
). The warning tells you which directory you need to add to PATH
to run the script simply by typing its name (e.g., script.exe
or script
).
Solution for Windows
Identifying the Required Path(s)
The warning message tells you the specific directory you need to add. It typically looks like:
C:\Users\YourUser\AppData\Local\Programs\Python\Python3XX\Scripts
Often, you'll want to add both this Scripts
directory and the main Python installation directory (e.g., C:\Users\YourUser\AppData\Local\Programs\Python\Python3XX
) to your PATH. This ensures both Python itself and its scripts are easily accessible.
You can find your Python installation path by running:
where python
:: OR
python -c "import os, sys; print(os.path.dirname(sys.executable))"
Adding Directories to PATH (System Properties GUI)
This is the standard graphical method:
- Search: Open the Windows search bar, type "environment variables", and select "Edit the system environment variables".
- System Properties: In the System Properties window that appears, click the "Environment Variables..." button.
- User Variables: In the Environment Variables window, look at the top section "User variables for [Your Username]". Find the
Path
variable in the list, select it, and click "Edit...". - Edit Environment Variable: Click the "New" button.
- Add Python Path: Click "Browse..." and navigate to your main Python installation directory (e.g.,
C:\Users\YourUser\AppData\Local\Programs\Python\Python310
). Select it and click "OK". - Add Scripts Path: Click "New" again. Click "Browse..." and navigate to the
Scripts
subdirectory within your main Python installation directory (e.g.,C:\Users\YourUser\AppData\Local\Programs\Python\Python310\Scripts
). Select it and click "OK". - Confirm: Click "OK" on the "Edit environment variable" window.
- Confirm Again: Click "OK" on the "Environment Variables" window.
- Final Confirm: Click "OK" on the "System Properties" window.
Restarting Your Shell (CMD/PowerShell)
Changes to environment variables usually only affect newly opened command prompts or PowerShell windows. Close any existing CMD or PowerShell windows and open a new one. In some cases, a full system restart might be necessary for the changes to be recognized everywhere.
Alternative: Modifying PATH via Python Installer
If you still have the Python installer (.exe
):
- Run the installer.
- Choose the "Modify" option.
- Proceed to the "Advanced Options" screen.
- Ensure the "Add Python to environment variables" checkbox is checked.
- Click "Install" to apply the changes.
Alternative: Reinstalling Python (Ensuring "Add Python to PATH")
If modifying isn't an option or things seem corrupted:
- Uninstall Python via "Add or remove programs".
- Download the latest Python installer from python.org.
- Run the installer.
- Crucially: On the first screen, check the box labeled "Add python.exe to PATH" (or similar wording like "Add Python X.Y to PATH").
- Continue with the installation ("Install Now").
Solution for Linux and macOS (Unix-like)
Identifying the Required Path (From the Warning)
The warning message directly tells you the path to add. Common examples include:
~/.local/bin
(When installing withpip install --user ...
)/usr/local/bin
(Common system location)/Library/Frameworks/Python.framework/Versions/X.Y/bin
(macOS system Python)/opt/homebrew/bin
or/opt/homebrew/opt/[email protected]/bin
(macOS Homebrew Python)
Use the exact path shown in your warning message.
Editing Your Shell Profile (.bashrc
, .zshrc
, .bash_profile
, etc.)
You need to add a line to your shell's configuration file to permanently add the directory to your PATH. The file depends on your shell:
- Bash: Usually
~/.bashrc
(for interactive non-login shells) or sometimes~/.bash_profile
(for login shells). If neither exists,~/.profile
might be used, or you can create~/.bash_profile
. - Zsh: Usually
~/.zshrc
.
Open the appropriate file using a text editor (like nano
, vim
, gedit
, etc.):
# Example using nano for bashrc
nano ~/.bashrc
# Example using nano for zshrc
nano ~/.zshrc
Add the following line at the end of the file, replacing /path/to/add/bin
with the actual path from your warning message:
export PATH="/path/to/add/bin:$PATH"
Explanation:
export PATH=...
: Sets the PATH variable for the current shell and any programs started from it."/path/to/add/bin"
: The directory containing the scripts (use the path from your warning). Quotes help if the path contains spaces, though this is rare for these types of paths.:
: The separator between directories in the PATH variable on Unix-like systems.$PATH
: Appends the existing value of the PATH variable. This ensures you don't overwrite directories already in your path. Adding the new path at the beginning means the shell will find scripts there first.
Save the file and exit the editor (e.g., in nano
, press Ctrl+X
, then Y
, then Enter
).
Applying and Verifying the Changes (source
, echo $PATH
)
For the changes to take effect in your current terminal session, "source" the file you just edited:
source ~/.bashrc # Or ~/.zshrc, ~/.bash_profile, etc.
Alternatively, simply close your current terminal window and open a new one.
Verify that the path has been added:
echo $PATH
You should see the path you added (e.g., /home/user/.local/bin
) listed somewhere in the output, separated by colons. If using .profile
, you might need to log out and log back in.
Verifying the Fix
After adding the path and restarting your shell (or sourcing your profile on Unix), try running the script name directly or checking the pip --version
:
# Example for Windows
pip --version
jsonschema --version # Try running the script mentioned in the warning
# Example for Linux/macOS
pip3 --version # Or just 'pip'
<script_name> --version # Try running the script mentioned in the warning
If the command is found without needing the full path, the PATH variable is now correctly configured.
General Pip Maintenance (Upgrading)
While not a direct fix for the PATH warning itself, keeping pip updated is good practice:
python3 -m pip install --upgrade pip
# Or python -m, py -m as appropriate
Conclusion
The WARNING: The script ... is installed in ... which is not on PATH
message from pip
means you need to update your system's PATH
environment variable so your shell can find the installed Python scripts.
- On Windows: Use the "Environment Variables" system settings GUI to add the Python installation directory and its
Scripts
subdirectory to your userPath
. Remember to restart your shell. - On Linux/macOS: Edit your shell's profile file (
.bashrc
,.zshrc
, etc.) and addexport PATH="/path/from/warning:$PATH"
.source
the file or restart your terminal.
Correctly configuring your PATH makes using Python command-line tools much more convenient.