“pip” is not recognized as an internal or external command – Code Example

Total
0
Shares

I have pip installed but when I try to install a Python module with the console with pip I get the following message:

“pip” is not recognized as an internal or external command, program, or executable batch file.

Solution

First of all, pip comes pre installed by default on any current version of Python, that you download from the official site. 

Indeed, the error is due to the fact that the script is not added to the PATH. But my recommendation is that you go directly from adding it and never use pip as a command. Except in Windows when the package itself updated pip

There are quite frequent errors due to installing with pip as a command without knowing the version of Python associated with it. Therefore we get the error like:

ModuleNotFoundError: No module named 'module_to_install' 🙂

The most reliable way to install a package is –

python -m pip install module_to_install

Since you’re using Windows you’ll have the Python Launcher installed. Tt’s installed by default if you didn’t uncheck the installer box. Perhaps the simplest way, so you can do:

py -m pip install module_to_install

py -3.7 -m pip install module_to_install

py -3.8 -m pip install module_to_install

etc, depending on the version you have installed.

If you didn’t have Python added to the path ( the installer has a checkbox that can be checked or unchecked to add it ) you can add it manually or use the absolute path, something like:

C:\users\tech\appdata\local\programs\python\python38-64\python.exe -m pip install module_to_install

Obviously change the path to your python.exe.


Solution 2

The problem is in the location of the PATH.

First you have to see the path where python is hosted.

In cmd console type –

where python

 It will provide you the location.

Once obtained the directory, Go to –


Control Panel > System and Security > System

You click on –

Advanced system settings

A window will open –

System properties

click on –

Environment Variables

At the bottom look for the variable Path, select it and click on edit. 

When the window opens: 

Edit environment variable

click on New. Enter the location or directory that appeared in the cmd console: C:\Users\%username%\AppData\Local\Programs\Python\Python39\

(note: do not add the extension python.exe with the directory). And finally click on accept. Restart your computer.


Solution 3

To check that pip has been installed, run in the terminal:

pip

And you should see the options for using the tool. 

If, on Windows, you get “pip” not recognized as an internal or external command, program, or executable batch file, you’ll need to access it manually.

C:\PythonXY\scripts\pip : Where X and Y correspond to the version number of Python

If all goes well, you have installed pip successfully!

Followed by that try to perform the installation like this for example: 

C:\PythonXY\scripts\pip install django

Solution 4

What worked for me was simply that I was referencing another version of python when using  –

pip install <modulo>

and I was pretty sure I had python installed. Turns out it was just that it didn’t reference python 3.x –

pip3 install <modulo>

as well as trying to run a script, using –

python3 <archivo>.py

Conclusion

The most practical thing, and the solution I have had having this same problem, is to uninstall Python and reinstall it. In the initial installation window, check the Add Path box. 

In this way, the installer automatically adds the Path’s to be able to access Python from anywhere in the system. In addition, the pip command will be the one that is linked to the version that you install.

Leave a Reply

Your email address will not be published. Required fields are marked *