Getting Oauth2 to work with Python on a Mac

I am ataking a coursera course in Data Science and having trouble getting the prelim check for the first assignment to run without errors.  Here are the details  any help is appreciated!

Using Mac OS 10.8.5
Which Python returns:

Running the first assignment script after updating teh API calls results in this:

$ python > output.txt
Traceback (most recent call last):
  File “”, line 1, in <module>
    import oauth2 as oauth
ImportError: No module named oauth2
So I go back double check my oauth2 installation

$ pip install oauth2
Traceback (most recent call last):
  File “/usr/local/bin/pip”, line 5, in
    from pkg_resources import load_entry_point
  File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/”, line 2603, in
  File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/”, line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/”, line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.5.2

So now I investigate PIP:

$ which pip
Not even sure what that means, but it’s there.

I investigate the pip file and see this, the version looks consistent internally with the error I am seeing above.

# EASY-INSTALL-ENTRY-SCRIPT: ‘pip==1.5.2′,’console_scripts’,’pip’
__requires__ = ‘pip==1.5.2’
import sys
from pkg_resources import load_entry_point
   load_entry_point(‘pip==1.5.2’, ‘console_scripts’, ‘pip’)()
I try easy install and get this result:

$ easy_install oauth2
error: can’t create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
    [Errno 13] Permission denied: ‘/Users/suzanne/Library/Python/2.7/site-packages/test-easy-install-8879.write-test’
The installation directory you specified (via –install-dir, –prefix, or
the distutils default setting) was:

SO I try with SUDO

$ sudo easy_install oauth2
Searching for oauth2
Best match: oauth2 1.5.211
Processing oauth2-1.5.211-py2.7.egg
oauth2 1.5.211 is already the active version in easy-install.pth
Using /Users/suzanne/Library/Python/2.7/site-packages/oauth2-1.5.211-py2.7.egg
Processing dependencies for oauth2
Finished processing dependencies for oauth2

This seems to have worked?  But I still get the ORIGINAL error above when running the file.

Do I have more than one python installed? THis command shows basically one (I think??)
$ type -a python

python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python
python is /usr/local/bin/python
python is /usr/bin/python
python is /usr/local/bin/python

When I look using my finder I do see folders for Python 2.3, 2.5, 2.6 and 2.7
I recall playing with Python installs awhile ago so I’m not sure if I added 2.7 myself and if that broke anything.

Here is my $PATH

$ echo $PATH

I am stuck.  I have googled/stackoverflowe searched everything I can think of and I can’t get the pre-assignment one command to work.

Any help? PLEASE??

  1 comment for “Getting Oauth2 to work with Python on a Mac

  1. Gauri
    September 20, 2015 at 10:48 am

    Try with sudo pip install oath.

    it worked for me.

Leave a Reply

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