Python:查找错误:未知编码:十六进制

编程入门 行业动态 更新时间:2024-10-15 12:37:11
本文介绍了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(稍后您会发现它很有用).

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

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

    Python:查找错误:未知编码:十六进制

    本文发布于:2023-06-11 14:50:29,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/637050.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:错误   Python   十六进制

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!