未知编码:Python请求中的idna [英] Unknown encoding: idna in Python Requests

查看:108
本文介绍了未知编码:Python请求中的idna的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python请求。一切正常,但今天我收到了这个奇怪的错误:

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

任何想法可能是什么错误?我使用的是来自brew的Python 2.7.2。

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

推荐答案

尝试添加:

import encodings.idna

筛选出其他错误。我在将Python连接到新平台上时遇到了同样的问题。我们只有部分库支持,缺少 unicodedata ,这导致idna模块的导入失败。一旦我们移植了 unicodedata ,此错误就消失了。

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.

这篇关于未知编码:Python请求中的idna的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆