Unknown encoding: idna in Python Requests
Asked Answered
T

1

13

I'm using Python Requests. All works great but today I get this strange error:

[...]
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/requests/models.py", line 321, in full_url
    netloc = netloc.encode('idna').decode('utf-8')
LookupError: unknown encoding: idna

Any ideas what could be wrong? I'm using Python 2.7.2 from brew.

Titus answered 4/2, 2012 at 21:30 Comment(3)
Is this being run through py2exe, or is it being run standalone? Also, try running import encodings.idna and see if that works.Overstate
import encodings.idna, encodings.ascii ImportError: No module named idnaTitus
Are you sure you are running Python 2.7.2? encodings.idna was not included before Python 2.3.Overstate
T
26

Try adding:

import encodings.idna

in various places to sift out other errors. I ran into this same problem working on a port of python to a new platform. We had only partial library support and unicodedata was missing which was causing imports of the idna module to fail. Once we ported unicodedata this error went away.

Tradition answered 24/10, 2012 at 21:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.