0

Having upgraded the version of python on my Mac OS X 10.6.8 from python 2.6 to python 2.7.10 I am getting the following error when I try to run pip commands in bash:

error –bash: pip: command not found 

I have tried installing pip with the command:

sudo easy_install pip 

… but am getting the error

python version 2.7.10 can't run /usr/bin/easy_install. Try the alternative(s): /usr/bin/easy_install-2.5 (uses python 2.5) /usr/bin/easy_install-2.6 (uses python 2.6) 

The problem is I removed these versions of python from my Mac when I updated to 2.7.10

Could anyone please suggest a solution that would help me to execute pip commands in bash?

** updated to show outputs as requested **

$ echo $PATH /Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin $ which -a python /usr/bin/python $ which -a pip # no output 

** updated to show further outputs as requested **

$ ls -lh /usr/local/bin/easy_install lrwxrwxr-x 1 root admin 74B 6 Sep 12:12 /usr/local/bin/easy_install -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install $ ls -lh $(which python) lrwxr-xr-x 1 root wheel 67B 6 Sep 12:18 /usr/bin/python -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python $ less /usr/local/bin/easy_install /usr/local/bin/easy_install: No such file or directory 
9
  • you can try python -m ensurepip followed by pip install --upgrade pip Commented Sep 6, 2015 at 13:03
  • Thanks for your response. I tried this and still got -bash: pip: command not found Commented Sep 6, 2015 at 13:11
  • Please add the output of echo $PATH, which -a python, which -a pip Commented Sep 6, 2015 at 13:42
  • Are you using Python or MacPort Python? Commented Sep 6, 2015 at 14:09
  • @MalikBrahimi Python I think Commented Sep 6, 2015 at 14:22

2 Answers 2

1

I don't know how you uninstalled Python from your computer, but you have left some utilities around that are still referring to older versions of Python.

The uninstall was not done completely or it was not done correctly.

Moving forward now, you have to decide what do you want to do. There are two scenarios:

  1. Run multiple versions of Python. The one that came with the operating system; and another version of your choice. You can then (optionally) set one of those as the default Python version.

  2. Completely remove all versions of Python, and have one installation across the entire system.

The recommended method is #1; as mentioned - there might be some utilities on your system that are relying on the bundled version of Python and may not function after a core-system upgrade. This is especially true on Linux; but less of a factor on Windows (since Python is not bundled with Windows).

According to your system output; your shell and system is still configured against the system-bundled version of Python.

The easiest way for you to move forward is to download the official installer for osx; and have it setup your system for you.

It will also ensure that pip is installed and configured correctly.

Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried (re-)installing setuptools from PyPI?

On a related note, removing previously installed Pythons can lead to all sorts of system breakage, as other programs may rely on the old versions. It'd probably be safer to alias your newly installed python in .bashrc, e.g.:

alias python27="/path/to/your/python2.7" 

The recommended way of hosting several versions of Python on the same machine is through virtualenv and virtualenvwrapper.

This section on installing packages from the Python Packaging User Guide addresses these issues.

17 Comments

Thanks for the answer, I have just followed the instructions and successfully installed setuptools 18.2 from PyPI but am still getting the error -bash: pip: command not found when I try to execute pip commands in bash. Worried to hear that removing previously installed versions of python can lead to system breakages.. Should I reinstall them?
setuptools should have set up easy_install. Would you try now to easy_install pip?
An alternative would be to download get-pip.py and run it using python get-pip.py.
re easy_install pip just tried this and receive the same error code: python version 2.7.10 can't run /usr/bin/easy_install. Try the alternative(s): /usr/bin/easy_install-2.5 (uses python 2.5) /usr/bin/easy_install-2.6 (uses python 2.6) Do you know what else I could try? Thanks again for your help
I agree that Apple default pythons would better be reinstalled, the discussion here might help.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.