Python:查找错误:未知编码:十六进制 [英] Python: LookupError: unknown encoding: hex

查看:37
本文介绍了Python:查找错误:未知编码:十六进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个名为 Tweepy 的 Twitter API.它一直工作正常,然后我重新启动了服务器,现在我得到了这个:

<预><代码>>>>导入 tweepy回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中文件tweepy/__init__.py",第 17 行,在 <module> 中从 tweepy.streaming 导入流,StreamListener 中的文件tweepy/streaming.py",第 16 行json = import_simplejson()文件tweepy/utils.py",第 83 行,在 import_simplejson 中将 simplejson 导入为 json文件build/bdist.linux-i686/egg/simplejson/__init__.py",第111行,在<module>文件build/bdist.linux-i686/egg/simplejson/decoder.py",第29行,在<module>文件build/bdist.linux-i686/egg/simplejson/decoder.py",第 21 行,在 _floatconstants查找错误:未知编码:十六进制

我也试过这个:

from encodings import hex_codec

它没有帮助.

知道为什么吗?

解决方案

我遇到了同样的问题(使用 json),解决方案是在您的 'encodings' Lib 文件夹中复制丢失的 'hex_codec.py' 文件:

确保您已安装 Python 2.7.X(稍后您会发现它很有用).

  1. 转到 Python 2.7.X 安装目录中的encodings"文件夹(例如,对于 Win 平台:C:\Python27\Lib\encodings")
  2. 将hex_codec.py"或每个.py"文件复制到build/bdist.linux-i686/egg/encodings"文件夹中....
  3. 利润

I'm using a Twitter API called Tweepy. It has been working fine, then I rebooted the server and now I'm getting this:

>>> import tweepy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tweepy/__init__.py", line 17, in <module>
    from tweepy.streaming import Stream, StreamListener
  File "tweepy/streaming.py", line 16, in <module>
    json = import_simplejson()
  File "tweepy/utils.py", line 83, in import_simplejson
    import simplejson as json
  File "build/bdist.linux-i686/egg/simplejson/__init__.py", line 111, in <module>

  File "build/bdist.linux-i686/egg/simplejson/decoder.py", line 29, in <module>
  File "build/bdist.linux-i686/egg/simplejson/decoder.py", line 21, in _floatconstants
LookupError: unknown encoding: hex

I tried this too:

from encodings import hex_codec

And it didn't help.

Any ideas why?

解决方案

I've been experiencing the same problem (with json), the solution is to copy missing 'hex_codec.py' file at your 'encodings' Lib folder:

Make sure you have Python 2.7.X installed (you'll find it useful later).

  1. Go to your Python 2.7.X installation directory for 'encodings' folder (ex. for Win platform: 'C:\Python27\Lib\encodings')
  2. Copy 'hex_codec.py' or every single '.py' file to your 'build/bdist.linux-i686/egg/encodings' folder. ...
  3. PROFIT

这篇关于Python:查找错误:未知编码:十六进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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