1

在导入烧瓶模块(或任何依赖于烧瓶的模块)时,我收到以下错误:

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'

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

>> uname -r
5.2.3-arch1-1-ARCH
>> pacman -Q --info python-flask
Name            : python-flask
Version         : 1.0.3-1
Description     : Micro webdevelopment framework for Python
Architecture    : any
URL             : http://flask.pocoo.org/
Licenses        : custom:BSD
Groups          : None
Provides        : None
Depends On      : python-werkzeug  python-jinja  python-itsdangerous  python-click
Optional Deps   : None
Required By     : python-flask-wtf
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 789.00 KiB
Packager        : Felix Yan <felixonmars@archlinux.org>
Build Date      : Sat 25 May 2019 10:31:00 AM IST
Install Date    : Sun 04 Aug 2019 01:11:45 AM IST
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

4

1 回答 1

1

我通过编辑上述文件解决了这个问题/usr/lib/python3.7/site-packages/flask/json/__init__.py

将第 21 行从

from itsdangerous import json as _json

import json as _json

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

于 2019-08-03T19:55:19.760 回答