Bash pip command not found windows

I am trying to install the SciPy stack located at https://scipy.org/stackspec.html [I am only allowed 2 links; trying to use them wisely]. I realize that there are much easier ways to do this, but I think there is a lot to be learned by doing it manually. I am relatively new to a lot of this stuff, so I apologize if I sound ignorant at any point.

I am running Windows 7 Enterprise - 64 bit. Here is what I have done so far:

  1. Installed python-2.7.8.msi (32-bit) from https://www.python.org/download/releases/2.7.8/

  2. Installed numpy-1.8.1-win32-superpack-python2.7 from
    http://sourceforge.net/projects/numpy/files/
    Test: import numpy as np —> no errors

  3. Installed scipy library,
    scipy-0.14.0-win32-superpack-python2.7.exe from
    (SCIPY DOT ORG LINK REMOVED)
    Test: import scipy as sp —> no errors

  4. Installed matplotlib: matplotlib-1.3.1.win32-py2.7.exe from
    (MATPLOTLIB DOT ORG LINK REMOVED)

  5. Installed PIP by running script here:
    https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py
    I just copied-pasted script to a new file in IDLE,
    saved as C:\Python27\Scripts\pip_install.py and clicked Run>module. No errors reported.

Does the path on which I saved
pip_install.py matter?


HERE IS WHERE I FAIL

Attempted to install matlibplot dependency dateutil: Opened a
Cygwin Shell, and typed

        cd C:\Python27          ! is it necessary to cd to python directtory?
        pip install python-dateutil

This results in the error:

    bash: pip: command not found

I get the same error attempting from cmd.

Any help is appreciated; the closest I found was bash: pip: command not found. But the OSX nature of it is just enough to confise me further.


UPDATE:

I added the pip-path per Paul H’s suggestion below. It made the error go away, but strangely, nothing I pip actually installs. For example, in Cygwin, I type:

cbennett2> pip install python-dateutil
cbennett2>                            

You can see that there is no output or feedback from the shell (which I think there should be). Then when I go to a new python shell:

>>> from dateutil.parser import parse
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    from dateutil.parser import parse
ImportError: No module named dateutil.parser
>>>>

This happens with all of the modules that I thought I had pip’d … pandas, tornado, etc.

Let’s say you receive an error message from Git Bash.

bash: pip: command not found

What Is a Pip Command Not Found Error?

A “pip: command not found” error occurs when you fail to properly install the package installer for Python (pip) needed to run Python on your computer. To fix it, you will either need to re-install Python and check the box to add Python to your PATH or install pip on your command line.

And an error message from DOS command line.

'pip' is not recognized as an internal or external command,
operable program or batch file.

What do you do? 

How to Fix Pip Command Not Found

If you’ve just installed Python, you may want to rerun your Python installer and make sure you check the box “Add Python 3.6 to PATH.”

pip command not found Python installer image

Python for Windows installer page. | Screenshot: Ashley Gelwix

If not, don’t worry. You can add Python and the pip directory to the PATH in a bit. Next, check here for pip3.exe:

C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts

Note that you can’t copy and paste that line. You will need to fill in your actual username in that path.

If you do find “pip 3,” you are in luck. It should look something like the image below.

pip command not found pip3 folder screenshot

The pip3.exe folder on Windows. | Screenshot: Ashley Gelwix

If you’re navigating on Windows, you can easily get to the AppData folder by typing the %appdata% macro into the path bar in a Windows File Explorer (formerly Windows Explorer) window.

pip command not found AppData search screenshot

Search %appdata% to get to the appdata folder on Windows. | Screenshot: Ashley Gelwix

If you can’t find the pip3.exe, it might not be installed. So, the first thing you should do is check to see that you did install pip. Run your Windows Python installer again and check the optional features page to ensure you marked the “pip” box. It’s easy to pass over these little things, and you may have missed it the first time through.

pip command not found python installer optional features

Check the install pip checkbox. | Screenshot: Ashley Gelwix

First, check that you’ve got the “pip” checkbox marked.

pip command not found advanced options screenshot

Mark “Add Python to environment variables” in advanced options. | Screenshot: Ashley Gelwix

Add Python to environment variables so that the Scripts folder with pip3.exe in it can be found. Then make sure that you’ve checked the box for adding Python to environment variables.

More on Coding ErrorsHow to Prevent Kubernetes Configuration Errors

How to Install Pip on the Command Line

If you don’t want to run your Python installer again, you can just install pip on the command line. 

It is also quite possible that you may have skipped over this warning right after summoning Python from the command line or after installation.

WARNING: The scripts pip.exe, pip3.6.exe and pip3.exe are installed in 'C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts' which is not on PATH.
 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

It’s easy to miss, and I think developers get into the habit of ignoring warnings like this because code often compiles with thousands of compiler warnings. 

Now, let’s edit your path. Start by searching for “environment” in your Windows search tab.

pip command not found environment variables screenshot

Search “environment” and edit the environment variables. | Screenshot: Ashley Gelwix

Then select, “Edit the system environment variables.”You will see a window like this below.

pip command not found system properties screenshot

In system properties, select environment variables. | Screenshot: Ashley Gelwix

Click the button the green arrow is pointing to labeled “Environment Variables.”

pip command not found environment variables path

Select the Path you want to edit. | Screenshot: Ashley Gelwix

You will then have a choice. You can either edit the user path or the system path. 

I usually edit the system path and have never run into issues. However, I suspect that the safer thing to do, the more “principle-of-least-privilege” thing to do, would be to edit the user path. That way only the user who needs pip access will have it. It’s up to you, but I typically never have more than one user on my machine. However, many workplaces do.

pip command not found edit paths screenshot

Click the Edit button for whichever path you chose

From there, you’ll want to copy the path we discussed earlier.

C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts

Make sure you use your actual username in the place of YOUR_USERNAME. Remember, you can’t just copy paste it. While you’re here, it’s also not a bad idea to add Python to your path. So, add this folder, too. It’s just one level up:

C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\

If you can’t open the path in File Explorer, it’s not a real path.

pip command not found edit environment variable screenshot

Paste in the Path and click OK. | Screenshot: Ashley Gelwix

Once you’ve pasted in the new path to the end of the path system environment variable, you can click OK to close the window. 

Next you need to restart the terminal, and type in “pip” to check your work. If it works, you should see the help output in the terminal. It should look something like the image below.

pip command not found help output in terminal screenshot

Pip help output in terminal. | Screenshot: Ashley Gelwix

If you don’t see it, you should go back to your path environment variable and make sure it is correct. Watch out for spaces in the wrong place, extra characters, etc.

More on PythonPython Tuples vs. Lists: When to Use Tuples Instead of Lists

The example path I gave you is on the C:/ drive. If you installed pip and Python to a different drive, use that one instead.

Alternatively, you could do this in your ~/.bashrc file for Git Bash. Enter, vim ~/.bashrc to open the bashrc file. This is a file that executes every time you open a shell window. You’ll have to re-open your shell to get the changes that you make to the bashrc file.

alias pip='C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\Python\\Python36\\pip3.exe'

A few other things to note:

  • You MUST use single quotes as double quotes will not work.
  • You MUST escape your \ slashes.
  • You MUST use Windows style slashes (\). Unix style (/) will not work.
  • You MUST escape your spaces in the path. If YOUR_USERNAME has a space you would enter the following: 
    alias pip='C:\\Users\\YOUR\ USERNAME\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\pip3.exe'

This can be handy if you don’t think you should edit the path. There’s more than one way to crack an egg. Creating an alias will just make pip automatically call that pip3.exe you pointed it to. However, you may need to add the “Scripts” folder to the path in order to find some modules you installed. 

On Windows especially, it seems to nearly always be safe to append to the path. But I always do that little trick to make sure I have an alias around just in case.

I am trying to install the SciPy stack located at https://scipy.org/stackspec.html [I am only allowed 2 links; trying to use them wisely]. I realize that there are much easier ways to do this, but I think there is a lot to be learned by doing it manually. I am relatively new to a lot of this stuff, so I apologize if I sound ignorant at any point.

I am running Windows 7 Enterprise - 64 bit. Here is what I have done so far:

  1. Installed python-2.7.8.msi (32-bit) from https://www.python.org/download/releases/2.7.8/

  2. Installed numpy-1.8.1-win32-superpack-python2.7 from
    http://sourceforge.net/projects/numpy/files/
    Test: import numpy as np —> no errors

  3. Installed scipy library,
    scipy-0.14.0-win32-superpack-python2.7.exe from
    (SCIPY DOT ORG LINK REMOVED)
    Test: import scipy as sp —> no errors

  4. Installed matplotlib: matplotlib-1.3.1.win32-py2.7.exe from
    (MATPLOTLIB DOT ORG LINK REMOVED)

  5. Installed PIP by running script here:
    https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py
    I just copied-pasted script to a new file in IDLE,
    saved as C:\Python27\Scripts\pip_install.py and clicked Run>module. No errors reported.

Does the path on which I saved
pip_install.py matter?


HERE IS WHERE I FAIL

Attempted to install matlibplot dependency dateutil: Opened a
Cygwin Shell, and typed

        cd C:\Python27          ! is it necessary to cd to python directtory?
        pip install python-dateutil

This results in the error:

    bash: pip: command not found

I get the same error attempting from cmd.

Any help is appreciated; the closest I found was bash: pip: command not found. But the OSX nature of it is just enough to confise me further.


UPDATE:

I added the pip-path per Paul H’s suggestion below. It made the error go away, but strangely, nothing I pip actually installs. For example, in Cygwin, I type:

cbennett2> pip install python-dateutil
cbennett2>                            

You can see that there is no output or feedback from the shell (which I think there should be). Then when I go to a new python shell:

>>> from dateutil.parser import parse
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    from dateutil.parser import parse
ImportError: No module named dateutil.parser
>>>>

This happens with all of the modules that I thought I had pip’d … pandas, tornado, etc.

If you are a developer either pro or novice and getting “Pip command not found error“. You have landed on the right page to find the solution. Majorly the reason is either you have not installed pip or the environment variable of pip is not set correctly. Based on the operating system, look for step by step solution to fix your pip command error.

What are the common errors, related to pip?

Below mentioned are very common errors you may encounter while working with Python and based on your operating system.

  1. Bash: pip: command not found
  2. Sudo pip command not found in Ubuntu
  3. Pip command not found in mac
  4. ‘pip’ is not recognized as an internal or external command, operable program or batch file
  5. pip command not found in Windows
  6. pyenv pip command not found
  7. pip command not found mac python 3
  8. zsh: command not found: pip

What are the quick fixes for “pip command not found error”?

  • Check for the existing installation of Python and pip versions in your system. Also, try the pip3 command instead of the pip
  • If pip is not installed, then install pip in the right way
  • If pip is installed, then make sure you have Path or environment variable set up correctly
  • Validate whether you are running python2 or python3 code and select your pip version accordingly. The recommendation is to move the codebase to Python and pip3 as Python2 is obsolete now.
  • Reinstall or upgrade Python and pip both, in case still getting pip command not found error
  • Exit out of the root user and run the pip command

What are Python and pip?

Python is a simple, Object-oriented, interpreted, high-level programming language with dynamic semantics. Due to its non-complicated syntax and fast edit-test-debug cycle, the Programmer community loves it. Python also reduces the cost of software management due to its simple nature. Python2 and Python3 are the two versions available, while Python2 is already obsolete and it’s suggested to move your codebase to Python3.

Pip is a package manager for python, it allows you to install and manage additional libraries and dependencies that are not distributed or part of the standard library.

*** For Windows10 and macOS, pip gets installed automatically with python3 as an option is available during installation. But in the case of Linux, you need to install pip3 after python3 installation separately.

If you are getting “bash: pip command not found error” in Ubuntu or any other Linux distro. You can fix it easily by following methods –

Solution 1- Check Whether Python and Pip are installed already or not?

I will take Ubuntu as a Linux distro for this post –

1.1 – Open Terminal in Ubuntu

Press <Ctrl + Alt + t> on your keyboard to open terminal.

1.2 – Check for the Python version installed in your Linux system

  • For python2. Python 2 is obsolete and it is recommended to move your codebase to python3.
$ python --version 
  • For Python3 which is by default installed in Ubuntu 20.04 or Ubuntu 21.04. In all new Linux distros, you get Python installed by default.
$ python3 --version

check-python3-version

In my case, Python 3.8.5 is installed by default. Visit my other article if you want to install the latest python and pip in Ubuntu Linux.

1.3 – Check for the existing pip version in Ubuntu 21.04

Run pip –version command to check, whether pip is also installed. Try running both commands, generally pip3 works in most cases.

$ pip --version 

OR

$ pip3 --version

pip command not found error

As you can see, I have got command ‘pip’ not found error. Because I have python 3 installed by default but not pip. So in Ubuntu make sure you always install pip as it’s not available by default.

  • To install pip you can simply run –
$ sudo apt update

$ sudo apt install python3-venv python3-pip

Check out this post, in case you get the sudo: command not found error. Once you are done with the installation, check the pip version again. Now you will not get the “pip command not found error” as it has been fixed already.

For alternate pip installation methods, you can refer to this official guide also.

1.4 (Optional) – Setup alias of pip3 as pip if required

In the case of Linux, you get pip and pip3 commands both after installing Python and Pip. If this is not the case, creating an alias is the only solution.

Add the following alias in $HOME/.bash_aliases in some cases, files may be hidden. You can also create it, in the case file doesn’t exist. Here option -m stands for the Module name.

alias pip="/usr/bin/python3 -m pip "

Refresh current terminal session

$ . ~/.profile

Solution2 – Setup path variable in Linux or macOS, in case pip3 is installed but still getting pip error

The path variable is set up by default during pip installation, but in case it doesn’t. Follow these steps to set up path variables in Linux or macOS.

  • Add this line to ~/.bash_profile using vi or nano editor.
export PATH="export PATH=/usr/bin/:/usr/local/bin:/usr/local/sbin:$PATH"
  • In a terminal window, run
source ~/.bash_profile

In the case of macOS, if you are using the zsh shell, then you can add it into the “.zshrc” file. Check out my other article, in case you get the zsh command not found error.

How to fix ‘pip’ is not recognized as an internal or external command, operable program or batch file in Windows 10

If you are getting the “pip command not found error” in Windows 10, follow these steps –

Solution3 – Install Pip during Python3 installation and setup path variable automatically

Step3.1- Python and pip download

You can download the latest python version 3.9.1 for windows or your respective operating system from the python.org website.

Download-python-3.9

Otherwise, you can simply click on the below-mentioned button to download python for windows 10.

Click here to download an older release of Python like 3.8 or 2.7, for your project. Once you click on this link, scroll down and select your old python version as shown in the image.

Download-old-python-releases

You don’t need to download pip separately as it’s part of Python 3.9.1 software. You will know it while following this post further.

Step3.2- Run Python 3.9.1 (64-bit) installer

Once your download completes, visit your “download” directory. Then double click python-3.9.1-amd64 file to start the python setup wizard.

Run-python-exe

Step3.3- Choose “Install Now” or “Customize” installation

At this point, You will get two installation options –

  1. Install Now – This option is helpful if you are a newbie. Just select “Install now” and it will install Python 3.9 with default settings. Python default installation directory would be “C:\users\”your-username”\AppData\Programs\Python\Python39”. It will also install IDLE, pip, documentation and shortcuts.
  2. Customize installation – If you are a pro and need to know, what all features will be installed with python. Also, in case you already have python installed and want to test the latest version. Using the Customize installation option, you can choose a different installation folder and can keep both python versions.

Keep following this post, if you want to see options covered in Customize installation.

how-to-install-python-on-windows

There are two more checkboxes to look into –

  • Install launcher for all users (recommended)” – Select this check box and it will make a python launcher shortcut for all user profiles that exist on your machine. Whomsoever will login to your system will be able to use python 3.9.
  • Add python 3.9 to the path – Select this check box to add Python and pip “Path Variables” in the system environment automatically. If you will not select this option now, you need to add the path variable manually later after installation. My recommendation is to select it here itself.

Step3.4- Add or remove “Optional Features

On this window, you can add or remove optional features, available with python 3.9. Let’s see a few details of each optional feature available –

  • Documentation:- Selecting this box will install all the Python documentation and manuals.
  • pip:- As I informed you in Step 1 download section. Pip is already part of python 3.9. Select this check box, If you want to install pip automatically with Python 3.9 (which I strongly recommend).
  • tcl/tk and IDLE:- Selecting this check box will install Tkinter and the IDLE development environment. You don’t need to install it separately then.
  • Python test suite:- Installs the standard library suite.
  • py launcher for all users (requires elevation):- Installs the global ‘py launcher for all users. It requires admin rights (elevation) to perform it. Because it will allow all users to launch python easily from their user profiles.

Choose your required optional features and click Next. I will suggest you keep all options checked.

select-optional-features-python

  • Select Next and complete the installation with default options.

Step3.5- Validate Python and pip versions

  • Open the elevated command prompt “as administrator” by typing “cmd” in the search bar of Windows 10.

open-command-prompt-windows10

  • Run the python or py (short form) command to check the Python version. You can see its version 3.9.1 installed in my case. You will see your installed version.
C:\> py 
### OR ###
C:\> python

How-to-check-python-version

Type exit() or press “Ctrl + Z” on your keyboard to exit from the python prompt.

  • To check the Python-pip version, type the pip –version command. it will show you the pip version. it’s pip 20.2.3 in my case.
C:\> pip --version

check-pip-version

Running the pip and python version command successfully also validates, that your python and pip path variables are added successfully in windows 10.

Solution4 – Setup the python Environment variable in Windows 10, in case forgot to select the option during installation

It’s very common to ignore options during the installation of any software in Windows 10. So if you are getting a “pip command not found” error in Windows 10, while you already have Python and pip installed. Then setting the environment up variables can fix this error.

Follow these steps –

  1. Search for environment variables in Windows 10 search box and select “Edit environment variables”
  2. Click Open
  3. Select the “Environment variables” tab
  4. Click on “PATH” in system variables and choose the “Edit” button.
  5. Click New
  6. Add this path, replace “Your_Username” with your user and Python39 with the python version, you have installed.
C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python39\Scripts

In my case, this path would be –

C:\Users\devender\AppData\Local\Programs\Python\Python39\Scripts

  • Save and close all open Windows of environment variable
  • Open a command prompt and run the pip –version command as shown in step 3.5 above. It will fix your issue of “pip’ is not recognized as an internal or external command, operable program or batch file in Windows 10“.

Refer to this image for further details –

Add pip path variable

Solution5 – Permission issues, exit root login to fix “pip command not found error”

$ sudo su -l root

Then run the pip command, you will not get the “pip command” errors.

pip <command>

Conclusion

Generally, pip is available with Python in all the latest versions for Windows. For Linux Python is installed by default, you just need to install the pip version.

If you have installed Python correctly, then the pip command not found error is rare. But if you are still having this error, I hope you would be able to fix it by following this article.

Let me know via your comments, in case you still face any issues, I will try to get this solved.

Один из распространенных вопросов, возникающих у новичков в Python, связан с ошибкой «bash: pip: command not found». Эта ошибка обычно возникает при попытке установить

Один из распространенных вопросов, возникающих у новичков в Python, связан с ошибкой «bash: pip: command not found». Эта ошибка обычно возникает при попытке установить библиотеку или модуль с использованием инструмента pip.

Возможная ситуация заключается в том, что pip был успешно установлен с помощью команды python setup.py install, но при попытке выполнить команду pip install <lib you want> возникает указанная выше ошибка.

Причина ошибки

Фактически, причина этой ошибки кроется в переменной среды PATH, которая определяет, в каких директориях операционная система будет искать исполняемые файлы. Если путь к исполняемому файлу pip не включен в переменную PATH, то bash (или ваша командная оболочка) не сможет его найти, и вы получите ошибку «pip: command not found».

Решение проблемы

Для решения этой проблемы нужно добавить путь к исполняемому файлу pip в переменную PATH. Для этого можно использовать следующие команды:

  1. Найдите, где установлен pip. Это можно сделать, например, командой find / -name pip. Эта команда найдет все файлы с именем pip в системе. Вывод этой команды может быть довольно большим, но вам нужно найти что-то похожее на ‘/usr/local/bin/pip’ или ‘/usr/bin/pip’.

  2. Добавьте найденный путь в переменную PATH. Это можно сделать, добавив следующую строку в файл .bashrc или .bash_profile (в зависимости от вашей операционной системы):

export PATH=$PATH:/path/to/pip

После выполнения этих шагов и перезапуска командной оболочки проблема должна быть решена.

  • Background task host windows 10 что это
  • Bash on ubuntu on windows how to
  • Bad system config info при загрузке windows 10 как исправить через консоль
  • Back to the future windows
  • Bash make command not found windows