We all know pip is the most important command while installing, upgrading, or managing any Python library. If you are new to Python you may face “pip is not recognized as an internal or external command” error while installing any package, this article is to show you different methods to solve or bypass this error.
While installing any Python package using pip command, you may get an error like below:
C:\Python38> pip install Django 'pip' is not recognized as an internal or external command, operable program or batch file. C:\Python38> pip install pandas 'pip' is not recognized as an internal or external command, operable program or batch file.
Solution1: Check Your Python Installation
This error typically occurs when the system cannot locate the
pip command in the system’s PATH. You should always make sure to check the box that says “Add Python to PATH” during the installation of Python or Anaconda in your system.
After installation, to check if Python is working, open a new command prompt and type
python --version. You should see your Python version.
To check if
pip is there, type
Solution2: Add pip Installation Path
If you miss to add variable path while installing Python, you can add that later. To add variable path, you need to find your Python installation directory. You need to provide Script path as the variable path.
I installed Anaconda Python inside D:\ drive. For me, the Script path is: D:\Anindya\D\Installation\Anaconda3\Scripts. So I am going to use that path as my variable path.
Once you find that, click the start icon and navigate to the Control Panel → System and Security → System. Then click “Advanced System Settings” on the right side of the panel (or simply you can search “variable” in the start search bar).
Once there, click Environment Variables on the bottom right and there will be two boxes, an upper and a lower box. In the upper box: Click on the ‘Path‘ Variable and click Edit located on the right. Click New and paste your directory Path. It should look something like this:
Click OK three times, open a new window of cmd, and type:
pip. See if it works. Now you should not get “pip is not recognized as an internal or external command” error.
Now this is the process to add pip path in Windows (I tried it in Windows 10). If you are using Linux or Ubuntu, you can do this by below
set command (this command will also work in Windows):
setx PATH "%PATH%;D:\Anindya\D\Installation\Anaconda3\Scripts"
Solution3: Use Python’s -m Flag
I know sometimes in office laptop it is difficult to edit variable path and installing fresh Python again. In that case, you can use
-m flag while installing any Python packages.
Python allows you to run modules as scripts using the
-m flag. Just type:
python -m pip install package-name and see if that works.
Just to Add
There are mainly three solutions to solve “pip is not recognized as an internal or external command” error, which I shared. It might sound silly, but sometimes we mess up the command because of a tiny mistake. Check carefully for typos or spaces in your command before going into those solutions.
Remember, the steps might change a bit depending on whether you’re using Windows, macOS, or Linux. Look up guides for your specific system to get accurate instructions.
Hi there, I’m Anindya Naskar, Data Science Engineer. I created this website to show you what I believe is the best possible way to get your start in the field of Data Science.