py4e icon indicating copy to clipboard operation
py4e copied to clipboard

AttributeError: module 'oauth' has no attribute 'OAuthConsumer

Open Peter7Hess opened this issue 7 years ago • 2 comments

Upon running sample code twitter1.py and it fails on this error:

$ python3 twitter1.py

Enter Twitter Account:mytwitter Traceback (most recent call last): File "twitter1.py", line 20, in {'screen_name': acct, 'count': '2'}) File "/Users/xxxxph/PycharmProjects/xxxxPy/twurl.py", line 10, in augment consumer = oauth.OAuthConsumer(secrets['consumer_key'],secrets['consumer_secret']) AttributeError: module 'oauth' has no attribute 'OAuthConsumer

any suggestions, the same error occurs if I try with oauth2

Peter7Hess avatar Jan 18 '18 01:01 Peter7Hess

This uses the oauth.py downloaded from the code3 folder, https://py4e.com/code3/ it's possibly PyCharm has a different version, or it's common for people to install OAuth (consider the only installs in the course are an editor/Python) , while OAuth2 is different in any case.

Downloaded all the files into a new folder, a hidden.py from 2015 and it's working fine.

srcatto avatar Jun 08 '18 21:06 srcatto

For future people who stumble across this issue: The oauth library has been updated and requires to instead of import oauth we must from oauth import oauth

BordenCT avatar Oct 05 '22 18:10 BordenCT

The entire Twitter code is no longer part of this course. They broke it all so bad that it is no longer mentioned in the book - Chapter 15 is completely rewritten - https://do1.dr-chuck.com/pythonlearn/EN_us/pythonlearn.pdf

Thanks.

csev avatar Jan 03 '24 04:01 csev