demjson报错:

python demjson 库 报错:AttributeError: 'dict' object has no attribute 'has_key'

Traceback (most recent call last):
  File "/root/github/stock/fund/stop_purchase_lof_fund.py", line 82, in fund_purchase_em
    data_json = demjson.decode(data_text.strip("var db="))
  File "/root/miniconda3/lib/python3.9/site-packages/demjson.py", line 2039, in decode
    j = JSON( strict=strict )
  File "/root/miniconda3/lib/python3.9/site-packages/demjson.py", line 910, in __init__
    self._asciiencodable = [32 <= c < 128 and not self._rev_escapes.has_key(chr(c))
  File "/root/miniconda3/lib/python3.9/site-packages/demjson.py", line 910, in <listcomp>
    self._asciiencodable = [32 <= c < 128 and not self._rev_escapes.has_key(chr(c))
AttributeError: 'dict' object has no attribute 'has_key'

对比了一下demjson这个库的版本,原来是旧版本的问题。

于是 去升级demjson的版本。

结果,又遇到下面的问题:

38a0fdd9c4c11f8bf3b13fe77bc2a128307f965c8d5fb4dc6d6f6beb79 (from http://mirrors.tencentyun.com/pypi/simple/demjson/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Downloading http://mirrors.tencentyun.com/pypi/packages/90/ad/1bc63e6dd7714640ad775cf4773d790794084444617e8fee65834b98ceb0/demjson-2.2.3.tar.gz (131 kB)
     |████████████████████████████████| 131 kB 4.2 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /root/miniconda3/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h6u09lvf/demjson_eb4df5ca7a414740a8baec070239e4b3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h6u09lvf/demjson_eb4df5ca7a414740a8baec070239e4b3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-shye_4u9
         cwd: /tmp/pip-install-h6u09lvf/demjson_eb4df5ca7a414740a8baec070239e4b3/
    Complete output (3 lines):
    /root/miniconda3/lib/python3.9/site-packages/setuptools/dist.py:757: UserWarning: Usage of dash-separated 'index-url' will not be supported in future versions. Please use the underscore name 'index_url' instead
      warnings.warn(
    error in demjson setup command: use_2to3 is invalid.

一波未平,一波又起。

解决办法:

降级setuptool

pip install "setuptools<58.0.0" 

然后就可以正常使用demjson了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值