New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError: No module named github #856
Comments
Change your current directory and try again? |
Do you mean simply move the script to another directory and try again? If that's what you meant, I tried and nothing changed. |
Is your script name also "github"? |
No, the Python script is not named "github". |
@JosephTLyons Did you run |
Yes, I did. And if I run it again, I get these messages to confirm it.
|
Hi, @JosephTLyons did you install py2 and py3 together in your MBP? |
@JosephTLyons Try to run the script on a terminal.... If this run successfully your IDE is bad configured |
I do have both python 2 (the version Apple ships with their mac) and python3 (installed through Homebrew). Also, I am running the script through Terminal, I'm not using an IDE. I'm coding strictly with Atom and then running with Terminal. |
Does a Python 2 virtualenv solve the problem? |
Where it will be used, python 2 is not used because of conflict. |
This seems to be one annoying known issue, let me investigate and try to fix. |
Can be a problem of PIP? I remember had this problem (with other module) on Linux Mate. |
Same issue. |
Try installing pygithub with this command: This ensures you're using the pip related to python interpreter that you're running the script with. |
i did it:
I tried running a script using pygithub and it did not return any error. |
it is good to try to run the script first from the command line of the virtual environment. |
These may be caused by the relative imports. Python 3 requires absolute imports. This should be fixed by #967 |
|
this breaks in python 3.7+ but works in 3.6.5 FYI |
I agree, have just tested it. When using Python 3.7+, getting following error:
Using Python 3.6 works fine. |
Does this still not work on Python 3.7 ??? Im still getting error when importing? |
@conoroshea1996 they have refused to fix this in the past despite multiple PRs to fix it. |
I have the same issue when I use Pycharm on Mac OS, but I do not have this issue when I use Jupyter on Mac OS. And, I do not have this issue when use Pycharm or Jupyter on Windows. |
+1 |
@p3nda This is almost certainly not the same issue as previously reported, can you show the full error? |
Hi @s-t-e-v-e-n-k , python3 --version I get: ImportError: cannot import name 'Github' from 'github' (/usr/local/lib/python3.7/site-packages/github/init.py) I figured this error is slightly different, so after troubleshooting for a while unsuccessfully I spun up a docker container and installed python3.6 and tried to use it: ImportError: cannot import name 'Github' |
@p3nda On which platform? |
@s-t-e-v-e-n-k For the first error on python3.7.4 i'm using macos mojave 10.14.6. In the docker container with python 3.6.9 i'm using Ubuntu 18.04.3 |
So it's odd, what does:
give you? |
And |
In Ubuntu 18.04 Docker container:
On my Mac:
I should note that i'm on my work machine this morning doing the test from the macbook which is |
Where did that /copy.py or /Users/amanada/copy.py file come from? It's masking a real Python module /usr/lib/python3.6/copy.py and causing a circular import. |
copy.py is a script I was working which uses PyGithub. When I ran those commands they were ran from the python interpreter itself after i tried running the script. I spun up a new container without running that script and just ran the import commands through python interpreter and works fine:
I'm not sure why adding it in my script broke everything, it's not even fully formed yet: import shutil ACCESS_TOKEN = '123456789' |
It broke everything because of the name -- it masks a Python module called 'copy' which is in the module import chain when you run |
Ah okay, thanks for the clarity @s-t-e-v-e-n-k i appreciate your time! |
@p3nda I'm delighted to help! I'm going to close this issue, if you have any other issues please feel free to open a new issue. |
Can someone help me with this error Traceback (most recent call last): |
In my case, I got this error due to issues with my Python imports path. I'm using Python 3.7.3: $ python3 --version
Python 3.7.3 And PyPI 20.2.3: $ pip3 --version
pip 20.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7) I have installed PyGithub: $ pip3 install pygithub
Requirement already satisfied: pygithub in /usr/local/lib/python3.7/site-packages (1.43)
Requirement already satisfied: pyjwt in /usr/local/lib/python3.7/site-packages (from pygithub) (1.7.1)
Requirement already satisfied: requests>=2.14.0 in /usr/local/lib/python3.7/site-packages (from pygithub) (2.24.0)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (1.25.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.0->pygithub) (2.10) But, it fails to import, nevertheless:
In the pip output, we saw that the package was installed to $ python3 <<< 'import sys; print(sys.path)'
['', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python37.zip', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/jhwill/Library/Python/3.7/lib/python/site-packages', '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages'] Solution 1: Add to
|
Is the a none or wasm wheel for this package? |
I run ubuntu server 22.04. I received this error quite frequently also. I believe it has to do with a failure to install packages pygithub actually depends on. for instance, my issues were related to the packages cffi and openssl. at least in my case, I noticed a large majority of the time, this error took place when installing from a requirements.txt file. in my case, I attempted to remove all related github packages (github or pygithub). in some cases, you may have installed pygithub/github from a reqs file. in which case: after removing some of the lost packages, these are the serious of commands that fixed it for me. if you get past this error, you may still have to manually install some required packages for your specific use case.
note: while I did receive the same error, I am aware that this esoteric solution may not work with everyone. at the very least, I hope this helps people further understand their own problem. good luck |
Really frustrating that this many years later and they still wont fix this even after multiple PRs to resolve it. |
I'm trying to use PyGitHub and I'm getting "ImportError: No module named github".
Setup specs:
macOS v10.13.6
Python v3.7.0
Installed with pip v18.0
The text was updated successfully, but these errors were encountered: