4

I have installed pip according to instructions on pip website. Downloaded get-pip.py and insatlled it with python get-pip.py. Got a confirmation saying installation is successful. Apparently the moment i type pip i get following error:

    [fh-mi-sdb99-ma:~/Downloads] sdb99% pip
/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py:211: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 8, in <module>
    load_entry_point('pip==6.1.1', 'console_scripts', 'pip')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2174, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1907, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py", line 211
    except PipError as exc:
                     ^
SyntaxError: invalid syntax

i am not sure why is this happening.. Any suggestion that would help me to get pip installed correctly on my mac?

Thanks!

EDIT:

[fh-mi-sdb99-ma:~/Downloads] sdb99% python --version
Python 2.7.9
[fh-mi-sdb99-ma:~/Downloads] sdb99% pip --version
/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py:211: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 8, in <module>
    load_entry_point('pip==6.1.1', 'console_scripts', 'pip')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2174, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1907, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Library/Python/2.5/site-packages/pip-6.1.1-py2.5.egg/pip/__init__.py", line 211
    except PipError as exc:
                     ^
SyntaxError: invalid syntax

Second EDIT:

I have installed python 3.5 pkg but still when i type python on terminal, python 2.7 is initiated..

  • possible duplicate of [Installing pip on Mac OS X](http://stackoverflow.com/questions/17271319/installing-pip-on-mac-os-x) –  Apr 30 '15 at 15:02
  • Did you install as sudo? I'm not sure if it is required, but without sudo, you may not have overwritten an original `pip` file that was using python2.5. – amccormack Apr 30 '15 at 15:13

2 Answers2

5

Your stack trace indicates that you are actually running python2.5

Verification

To verify your python version run python --version.

I would also verify your pip version by running pip --version.

Using the correct python

If you already installed python2.7, you can often specify it specifically, for example: python2.7 my_module.py. Try typing python in your terminal and tap TAB twice. This will list all the python* programs you have in your path. If python2.7 is not listed, you will need to install it.

Using the correct pip

Similar to the above about using the correct python, you should ensure you are using the correct pip. Try typing pip into your terminal and tap TAB twice. This will list any extra pip versions you have. It is often easier to specify pip2.7.

Download and install Python3.4

If you haven't made a firm decision between python2 and python3, a nice feature of python3 is that python3.4 is bundled with pip, so you don't have to do anything to use it.

amccormack
  • 13,207
  • 10
  • 38
  • 61
  • see the edit. i have typted both your suggestions and giving you outcome of that in edit – learnningprogramming Apr 30 '15 at 15:06
  • I have installed python3.5 through installer from python website.. but stil when i type python on terminal i get python 2.7.9 – learnningprogramming Apr 30 '15 at 15:24
  • Have you tried the `TAB` trick mentioned above? It should list multiple versions of python. If it doesn't I would reinstall python, and be sure to use superuser privileges. – amccormack Apr 30 '15 at 15:28
  • yes i tried that but no other version of python is listed when i press TAB for two times .. – learnningprogramming Apr 30 '15 at 16:27
  • If only one `python` is listed in your path, and (based on your edit to the question), you `python --version` lists `Python 2.7.9` then I would have to conclude that you did not install python3 fully or correctly. I would try reinstalling it. – amccormack Apr 30 '15 at 16:32
  • would you recommend installing it again by installer or throughh comman dprompt – learnningprogramming Apr 30 '15 at 16:35
  • 1
    I would download the '.pkg' file for `Python 3.4.3`. It will walk you through the install process, prompting for your password. – amccormack Apr 30 '15 at 16:51
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76664/discussion-between-amccormack-and-tryeverylanguage). – amccormack Apr 30 '15 at 17:16
2

Update

Python 2 is end-of-life. Python 3.4+ comes with pip

Original Answer

You are using Python 2.5, outdated version:

   /Library/Python/2.5/

Please install at least Python 2.7 first:

https://www.python.org/downloads/

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • when i type python --version it gives me Python 2.7.9 – learnningprogramming Apr 30 '15 at 15:08
  • try `which pip` and then you see `pip` command you run is not probably against Python 3.7. You probably need to reinstall Python, reinstall pip and make sure pip gets installed against the correct Python. If needed, use full path to start python, eg. `/usr/local/bin/python` – Mikko Ohtamaa Apr 30 '15 at 15:09