1

Recently had a fun project idea and wanted to utilize the GitHub API, so I searched around for a Python wrapper. On the GitHub libraries page I found github3.py

After looking at their docs

I get an error saying AttributeError: 'GitHub' object has no attribute 'me', from this code example

from github3 import login

gh = login('sigmavirus24', password='<password>')

sigmavirus24 = gh.me()
# <User [sigmavirus24:Ian Cordasco]>

print(sigmavirus24.name)
# Ian Cordasco
print(sigmavirus24.login)
# sigmavirus24
print(sigmavirus24.followers_count)
# 4`

Is there something I'm missing from the documentation? Or have the docs just not been updated?

How do I fix this problem? I tried running dir(gh) to view attributes of the login object, but that's not telling me much, and have tried using Python 2.7.11, and Python 3.4.3.

6
  • Does importing the Github class fix your issue? First line should read from github3 import login, Github. Commented Feb 18, 2016 at 21:45
  • 1
    @mech OP isn't using the Github class in their code, so importing it won't do anything. Commented Feb 18, 2016 at 21:50
  • 1
    @mech Importing GitHub, doesn't do anything. Commented Feb 18, 2016 at 21:53
  • Nevermind then, I misread some of the docs while reading over them. Thanks for checking! Commented Feb 18, 2016 at 21:53
  • What is the output of import github3; print(github3.__version__)? Commented Feb 18, 2016 at 21:59

1 Answer 1

3

The documentation you linked to in your question is for version 1.0.0a3, whereas you are running 0.9.5. If you look at the same code snippet in the 0.9.5 docs, you'll see the syntax is slightly different:

from github3 import login

gh = login('sigmavirus24', password='<password>')

sigmavirus24 = gh.user()
#                 ^^^^ instead of me()

If you want to use the latest version, download and install from the wheel. Or, if you want to continue using your current version, just follow the 0.9.5 docs I linked to above.

Also, one other hint - to list the methods and attributes available for a particular object, use dir(objectname) instead of help().

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

1 Comment

Oops. Just edited my question. I did in fact use dir(). Hmm... Don't know how I missed that small issue. Thanks Matt!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.