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).
I've encounter this problem too, but it happed on a computer that I didn't have access to.
I've renamed encodings/hex_codec.py (and deleted the .pyc) look like what will make this error happen
ActivePython 2.7.0.2 (ActiveState Software Inc.) based on
Python 2.7 (r27:82500, Aug 23 2010, 17:18:21) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\json\__init__.py", line 108, in <module>
from .decoder import JSONDecoder
File "c:\Python27\lib\json\decoder.py", line 24, in <module>
NaN, PosInf, NegInf = _floatconstants()
File "c:\Python27\lib\json\decoder.py", line 18, in _floatconstants
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
LookupError: unknown encoding: hex
>>>
check your files, hex_encoding is probably missing. or you might have something weird in your PATH / PYTHON_HOME
can you do printenv before running you code ? and "print sys.path" in the interpreter ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With