Skip to content
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

Python 2.7 Error - ImportError: cannot import name Github #472

Closed
azatelli opened this issue Oct 11, 2016 · 24 comments
Closed

Python 2.7 Error - ImportError: cannot import name Github #472

azatelli opened this issue Oct 11, 2016 · 24 comments

Comments

@azatelli
Copy link

import github works but nothing seems to be under github. Using Python 2.7.

pip install PyGithub

Thoughts?

@andrewgross
Copy link

from github import Github is the best way to get started. Check the documentation for some examples of how to use different auth types.

@10c8
Copy link

10c8 commented Oct 12, 2016

from github import Github will result in an error stating that MainClass doesn't exist.

@andrewgross
Copy link

Hmm, that is very strange, possible that you have conflicting dependencies? Can you list the results of pip freeze?

@azatelli
Copy link
Author

pip freeze:

prettytable==0.7.2

PyGithub==1.29

requests==2.11.1

On Wed, Oct 12, 2016 at 10:23 AM, Andrew Gross notifications@github.com
wrote:

Hmm, that is very strange, possible that you have conflicting
dependencies? Can you list the results of pip freeze?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#472 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJPI7AQ-d-K0ux--s9819NQZtMDT0EHks5qzO1IgaJpZM4KTIZ4
.

@andrewgross
Copy link

In the directory you are working in, do you have a file called github.py? (or a folder with an __init__.py inside of it?

@azatelli
Copy link
Author

Yes sir.

On Wed, Oct 12, 2016 at 10:51 AM, Andrew Gross notifications@github.com
wrote:

In the directory you are working in, do you have a file called github.py?
(or a folder with an init.py inside of it?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#472 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJPIx7SioI6d7e4qTTN4VZaRIIUtY-Bks5qzPP7gaJpZM4KTIZ4
.

@azatelli
Copy link
Author

Yes sir, github.py

On Wed, Oct 12, 2016 at 11:27 AM, Anthony Zatelli azatelli@gmail.com
wrote:

Yes sir.

On Wed, Oct 12, 2016 at 10:51 AM, Andrew Gross notifications@github.com
wrote:

In the directory you are working in, do you have a file called github.py?
(or a folder with an init.py inside of it?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#472 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJPIx7SioI6d7e4qTTN4VZaRIIUtY-Bks5qzPP7gaJpZM4KTIZ4
.

@andrewgross
Copy link

Yep, that'll do it. Python will try to import from that file first, try changing the name of your local file and it should work.

@azatelli
Copy link
Author

Awesome! Thank you. :)

On Wed, Oct 12, 2016 at 11:41 AM, Andrew Gross notifications@github.com
wrote:

Yep, that'll do it. Python will try to import from that file first, try
changing the name of your local file and it should work.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#472 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJPIyvN4e2IXEfvfN7o-8OD0HisOCSpks5qzP_CgaJpZM4KTIZ4
.

@tzatter
Copy link

tzatter commented Nov 13, 2016

I met the same problem. then I got here. Thank you!

@nirzari
Copy link

nirzari commented Mar 13, 2017

I was facing the similar issue. This helped. Thanks

@AsinRay
Copy link

AsinRay commented May 16, 2018

I met the same problem. then I got here. Thank you!

@prakhar21
Copy link

Thanks @andrewgross

@enricorotundo
Copy link

LOL we all got into the github.py trap 🤖

@jbradforddillon
Copy link

Haaaaaa. yep. Thanks for this!

@docktermj
Copy link

Just fell into the trap myself.

@abubelinha
Copy link

me too

@neiltranter
Copy link

me too!

@toughjay318
Copy link

@andrewgross so I don’t have a file named github.py, but I do have a folder labeled ‘’’init.py’’’. I am receiving the same Import error for github

@andrewgross
Copy link

Is your folder named github?

@toughjay318
Copy link

toughjay318 commented Apr 2, 2023 via email

@andrewgross
Copy link

Ok, you should make sure you don't have a folder, file or class named Github to avoid the import issues.

@rparamanandam-equinix
Copy link

This is fixed my issue
pip3 install --upgrade pip
pip3 install --upgrade pygithub

1 similar comment
@kumgaurav
Copy link

This is fixed my issue
pip3 install --upgrade pip
pip3 install --upgrade pygithub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests