0

I want to try PyGitHub a Python library to access the GitHub REST API.

python imterpreter: anaconda python 3.10

the first step, I install the command

pip install PyGithub

enter image description here

after that, I try to follow the tutorial to create a GitHub instance:

from github import Github
from github import Auth
auth = Auth.Token("access_token")
g = Github(auth=auth)
g = Github(auth=auth, base_url="https://{hostname}/api/v3")

This error message how to solve

from github import Auth
ImportError: cannot import name 'Auth' from 'github'
Bill
  • 11
  • 5
  • I had the same issue, turned out my IDE was using my system default's python interpreter, not the virtual env one. So you either didn't install the module in your python venv or whichever env your interpreter uses – mveroone Aug 17 '23 at 07:47

1 Answers1

0

Having the same problem with importing Auth.

The old approach still works, even though I have no idea which approach is better.

from github import Github

access_token = "your GH access token" 

gh = Github(access_token)

for repo in gh.get_user().get_repos():
    print(repo.name)

I put the access token as a string in the code for simplicity. In my actual code, I am using a config file to import the token.

akalanka
  • 553
  • 7
  • 21