Community-maintained Python library for GitHub REST API v3. Current version is 2.8.1 (Feb 2026). Note: package name on PyPI is 'PyGithub' (capital P and G) but imports as 'github' (lowercase). Not an official GitHub SDK.
pip install PyGithubVerified import paths — ran on the pinned version, not inferred.
Minimal authenticated GitHub API call using PyGithub 2.x auth pattern.
auth = Auth.Token('ghp_...'); g = Github(auth=auth)Use commit.files.totalCount or iterate instead of len()
Use .totalCount property instead of len()
Add tzinfo=timezone.utc to any datetime instances used in comparisons
pip install PyGithub && from github import Github
Use as context manager: with Github(auth=auth) as g: ...
Replace position=N with line=N
For official REST access use requests + Authorization header directly, or use PyGithub.
Ensure the GitHub token is correct, not expired, and has the required scopes for the API calls being made. Check GitHub token settings or regenerate a new token with appropriate permissions.
Ensure PyGithub is installed in your current environment using: pip install PyGithub
Use the older authentication method: from github import Github; g = Github('access_token')Correct the import statement to: from github import Github
Use the 'get_dir_contents' method instead: contents = repo.get_dir_contents('path')Ensure the repository or user exists and is accessible: repo = g.get_repo('owner/repo')No dependency data recorded yet.