Explain Codes LogoExplain Codes Logo

Pipenv: Command Not Found

python
pipenv
installation
troubleshooting
Alex KataevbyAlex Kataev·Mar 2, 2025
TLDR

Getting a pipenv: command not found error? It's likely that pipenv is either not installed or not in your PATH. Install it with:

pip install --user pipenv

Next, add pipenv to your PATH. Update your shell configuration file (like ~/.bashrc) with the output of $(python -m site --user-base)/bin:

echo 'export PATH="$(python -m site --user-base)/bin:$PATH"' >> ~/.bashrc source ~/.bashrc

Now, your shell can access pipenv commands.

Unpacking the PATH

Often, pipenv: command not found arises because PATH (an environment variable) doesn't include the pipenv installation directory. Herein lies our first detective clue. 🔍

Battle of Installations: Global vs User

  • Global Install: Uses sudo, affects all users on your system but might need an admin password. But hey, who doesn't like some power?
    sudo pip install pipenv
  • User Install: No sudo, and the changes only apply to you.
    pip install --user pipenv

Python Environments and the Usual Suspects

Different environments and Python versions can contribute to our missing pipenv.

  • Python 2 vs. Python 3: Some systems default to Python 2. To call Python 3, replace python with python3:
    pip3 install --user pipenv
  • User Environment: If you're using --user, extend your PATH to include the user base's binary directory.

A Mac User's Guide to PATH Finding

If you're using a Mac, binaries like pipenv often lurk in /usr/local/bin. If pipenv STILL plays hide and seek, consider upgrading pip:

sudo pip3 install --upgrade pip pip3 install pipenv

Deep-diving into Troubleshooting

Clean Slate: Uninstall & Reinstall

At times, starting afresh is your best bet. If you're still at odds with pipenv, uninstall and reinstall:

pip uninstall pipenv pip3 uninstall pipenv pip3 install pipenv

Brew vs Pip on Mac

Mac users who've installed Python via Homebrew, check for potential conflicts. If suspicions are high, uninstall via Homebrew, then reinstall utilizing pip.

Invoking as a Module

If the direct pipenv command refuses to work, here's a workaround: run it as a Python module:

python -m pipenv

Validating the Installation

Double-check and validate the pipenv installation by confirming its presence in PATH:

echo $PATH | grep $(python -m site --user-base)/bin

The Official Guide is Your Friend

When in doubt, always refer to pipenvs official installation guide for reliable and updated information.