pipenv is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# pipenv is not recognized as an internal or external command

The error "'pipenv' is not recognized as an internal or external command, operable program or batch file" occurs when we forget to install pipenv before running the command.

To solve the error, install the pipenv package by running the pip install pipenv command.

pipenv is not recognized as internal or external command

Make sure you have pipenv installed by running the following command in cmd.

cmd
pip install pipenv # ๐Ÿ‘‡๏ธ for Python 3 pip3 install pipenv # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python -m pip install pipenv # ๐Ÿ‘‡๏ธ using py alias py -m pip install pipenv # ๐Ÿ‘‡๏ธ for Python 3 python3 -m pip install pipenv # ๐Ÿ‘‡๏ธ If you get a permissions error pip install pipenv --user

You should now be able to use the pipenv command as follows.

cmd
pipenv --help pipenv --version python -m pipenv --help python -m pipenv --version py -m pipenv --help py -m pipenv --version

If the installation command doesn't succeed, try running CMD as an administrator.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

If you get the error "'pip' is not recognized as an internal or external command", use the python -m command when installing pipenv.

shell
# ๐Ÿ‘‡๏ธ first uninstall `virtualenv` and `pipenv` python -m pip uninstall virtualenv pipenv -y py -m pip uninstall virtualenv pipenv -y python3 -m pip uninstall virtualenv pipenv -y # ๐Ÿ‘‡๏ธ now install `pipenv` python -m pip install pipenv py -m pip install pipenv python3 -m pip install pipenv

You can also try to upgrade the package with the --upgrade option.

shell
python -m pip install pipenv --upgrade py -m pip install pipenv --upgrade python3 -m pip install pipenv --upgrade

If you see an error message that "ps1 cannot be loaded because running scripts is disabled on this system", run the following command, type "yes" when prompted and rerun the activation command.

PowerShell
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
You can verify that the pipenv module is installed by using the pip show pipenv command.
PowerShell
pip show pipenv pip3 show pipenv python -m pip show pipenv py -m pip show pipenv python3 -m pip show pipenv

The pip show pipenv command will either state that the package is not installed or show a bunch of information about the package, including the location where the package is installed.

If the error persists, you have to add Python to your user's PATH environment variable.

# Add Python to your user's PATH environment variable

To add Python to your user's PATH environment variable:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "User variables for YOUR_USER" section, select the "Path" variable and click "Edit".

select user path click edit

  1. Click on "New" and then click "Browse".

click new browse

  1. You can use one of the following commands to check where your Python installation is located.
cmd
python -c "import os, sys; print(os.path.dirname(sys.executable))" where python

find python path

For me, the path is the following.

cmd
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310

Note that I have Python 3.10 installed, which is reflected in the PATH.

  1. Add the path to Python and then add the path to the Scripts directory that is located in your Python3X folder. This is where the executable files are located.

For me, it is the following path.

cmd
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts

add scripts folder

  1. Once the two paths are added, confirm the changes by clicking on the "OK" button twice.

added python and pip to path

  1. Close your Command prompt application and then reopen it.
Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

If you still encounter issues, try to add Python to your PATH using the official installer.

  1. Download the installer from the official python.org website.

  2. If you have Python already installed, start the installer and click on "Modify".

click modify

You can leave the optional features ticked.

optional features

  1. On the "Advanced Options" screen, make sure to tick the "Add Python to environment variables" option.

add python to environment variables

  1. Once the "Add Python to environment variables" checkbox is checked, click "Install".
Now your Python installation should be set up correctly and Python should be added to your user's PATH environment variable.

If that didn't work, your Python installation might be corrupted.

Start the installer again and click on "Uninstall".

uninstall python

Now that you don't have Python installed on your machine, start the installer again and make sure to tick the "Add python.exe to PATH" option.

add python exe to path

The checkbox won't be checked by default.

Once the "Add python.exe to PATH" checkbox is checked, click on "Install Now".

After the installation, Python will be installed and configured properly.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev