This will install the package.
pip3 install PyGithub
If you're getting the same error that could be due to circular imports. Rename if you have any .py files named "github.py" in your work folder.
Answer from nrnw on Stack OverflowThis will install the package.
pip3 install PyGithub
If you're getting the same error that could be due to circular imports. Rename if you have any .py files named "github.py" in your work folder.
Try to check your python version, create a virtualenv with python==3.9 will solve the problem of github api. I tried with python3.11 or greater therow"No module named github"
ModuleNotFoundError: No module named 'github'
python - ModuleNotFoundError: No module named github, on raspberry pi - Stack Overflow
python - fixing an 'from github import Github' error - CS50 Stack Exchange
ModuleNotFoundError: No module named. In github actions by using pytest
Hello :) ,
I'm a newbie, started messing around with python a few days ago.
I find myself sitting hours about this shit actually.
No matter what I do, almost always when I run the python script I get an ModuleNotFoundError, and it doesn't even matter what package it is.
For example I'm trying to import the PyGithub module for a small project:
when using the command python [name_of_the_script], it returns: ImportError: No module named github
when using the command python3 [name_of_the_script], it returns:
Traceback (most recent call last):
File "app.py", line 3, in <module>
import github
File "/home/mectos/.local/lib/python3.8/site-packages/github/__init__.py", line 58, in <module>
from github.MainClass import Github, GithubIntegration
File "/home/mectos/.local/lib/python3.8/site-packages/github/MainClass.py", line 56, in <module>
import requests
File "/home/mectos/.local/lib/python3.8/site-packages/requests/__init__.py", line 112, in <module>
from . import utils
File "/home/mectos/.local/lib/python3.8/site-packages/requests/utils.py", line 25, in <module>
from . import certs
File "/home/mectos/.local/lib/python3.8/site-packages/requests/certs.py", line 15, in <module>
from certifi import where
ModuleNotFoundError: No module named 'certifi'when using the command python3.8 [name_of_the_script], it returns:
Traceback (most recent call last):
File "app.py", line 3, in <module>
import github
File "/home/mectos/.local/lib/python3.8/site-packages/github/__init__.py", line 58, in <module>
from github.MainClass import Github, GithubIntegration
File "/home/mectos/.local/lib/python3.8/site-packages/github/MainClass.py", line 56, in <module>
import requests
File "/home/mectos/.local/lib/python3.8/site-packages/requests/__init__.py", line 112, in <module>
from . import utils
File "/home/mectos/.local/lib/python3.8/site-packages/requests/utils.py", line 25, in <module>
from . import certs
File "/home/mectos/.local/lib/python3.8/site-packages/requests/certs.py", line 15, in <module>
from certifi import where
ModuleNotFoundError: No module named 'certifi'important note:
The thing is, it changes the "required" package every time. The scenario is as follows:
I get this error about the certain module
I run
pip3 install [package]it tells me that it already exists in
/usr/bin/python3.8/dist_packages-> I navigate to this directorymanually run
sudo rm -rf [package]then run again
pip3 install [package]it downloads it successfully
I try again
[python/python3/python3.8] [name_of_the_script]And then it returns that some another random package is missing.
I presume I have some kind of problem with my packages or PYTHONPATH or whatever?
I'm actually baffled, started with python after a few months with HTML, CSS, JS and JS's package manager npm. So things are slightly different here in Python compared to JS.
Much appreciations in advance for all the help!
The git module is not the same thing as the git command line executable. They happen to have the same name and cover related tasks, but they are distinct software packages.
I'm going to assume that the git module your code is importing is the one provided by the GitPython project. You'll need to install that project, see their installation instructions:
# pip install gitpython
In my cas, I installed pythong2-git, it solved my problem.
sudo apt-get install python3-git
What worked in my case, on Windows, was
python3 -m pip install gitpython
Even after installing GitPython through pip3, the module was not being found, even if I included the appropriate paths. What worked is the command I mention.
Following Installing GitPython, a simple pip install GitPython should be enough.
If not, check gitpython-developers/GitPython issue 1051:
Even though I don't know what is causing this I do know that GitPython 2.x is supposed to work with Python 2 and 3, whereas GitPython 3 only works with Python 3.
It's hard to understand what exactly happened here, but when running pip3 install GitPython I am also unable to successfully run
import git.My best guess is that pip installs things outside of the PYTHONPATH, which certainly is surprising