AttributeError:模块“ simplejson”在“导入烧瓶”上没有属性“转储”

时间:2019-08-03 19:52:00

标签: python python-3.x flask itsdangerous

在导入flask模块(或任何依赖于flask的模块)时,出现以下错误:

def update_porembei(request, id):
    porembei = get_object_or_404(Porembei, id_porumbel=id)
    if porembei.crescator != self.request.user:
        raise PermissionDenied()

我的系统和软件包详细信息:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from flask import Flask, request, render_template, redirect, abort, make_response
  File "/usr/lib/python3.7/site-packages/flask/__init__.py", line 21, in <module>
    from .app import Flask, Request, Response
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 26, in <module>
    from . import cli, json
  File "/usr/lib/python3.7/site-packages/flask/json/__init__.py", line 26, in <module>
    _slash_escape = '\\/' not in _json.dumps('/')
AttributeError: module 'simplejson' has no attribute 'dumps'

1 个答案:

答案 0 :(得分:0)

我通过编辑上述文件/usr/lib/python3.7/site-packages/flask/json/__init__.py

解决了该问题

更改第21行,

from itsdangerous import json as _json

收件人

import json as _json

这不是解决此问题的正确方法,因此我将等待正确的答案并立即使用此修复程序。