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

AttributeError: module 'urllib' has no attribute 'urlencode' #15

Closed
uzabumuhire opened this issue Feb 17, 2019 · 2 comments
Closed

AttributeError: module 'urllib' has no attribute 'urlencode' #15

uzabumuhire opened this issue Feb 17, 2019 · 2 comments

Comments

@uzabumuhire
Copy link

I am using Docker to run Jupyter Notebook on Mac OS Mojave 10.14.13 and "Appendix B - OAuth Primer" section "Example 2. Facebook OAuth 2.0 Flow" can't compile and generate the following error:

AttributeError Traceback (most recent call last)
in
62 )
63
---> 64 oauth_url = 'https://facebook.com/dialog/oauth?' + urllib.urlencode(args)
65
66 Timer(1, lambda: display(JS("window.open('%s')" % oauth_url))).start()

AttributeError: module 'urllib' has no attribute 'urlencode'

To resolve the issue I have found help on this Stack Overflow link https://stackoverflow.com/questions/28906859/module-has-no-attribute-urlencode and their proposed solution is :

urllib has been split up in Python 3. The urllib.urlencode() function is now urllib.parse.urlencode(), and the urllib.urlopen() function is now urllib.request.urlopen().

By changing line 64 oauth_url = 'https://facebook.com/dialog/oauth?' + urllib.urlencode(args) to oauth_url = 'https://facebook.com/dialog/oauth?' + urllib.parse.urlencode(args) the error goes away.

@mikhailklassen
Copy link
Owner

Hi @uzabumuhire -- Thanks for catching these holdovers from Python 2. I've now changed
urllib.urlencode() to urllib.parse.urlencode(), which is the correct way to call it in Python 3.

I've removed firends_likes from the EXTENDED_PERMS list. Facebook has removed that permission from the API, so we can't make use of it anymore.

I've tested the code on my end and got it to run successfully. Please let me know if you have any other problems with it. I will close this issue for now.

@Amir-Mohamad4
Copy link

why i cant use urllib2 ? i use import urllib.request as urllib2 ........ but when i want to use , it gaves me lots of error , for example it gaves me some attribute errors !!!

thank you :)

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

3 participants