有以下Pipfile
:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
mypy = "*"
pytest = "*"
flake8 = "*"
[packages]
flask = "*"
sqlalchemy = "*"
flask-sqlalchemy = "*"
alembic = "*"
marshmallow = "*"
flask-marshmallow = "*"
flask-restful = "*"
psycopg2 = "*"
python-dotenv = "*"
marshmallow-sqlalchemy = "*"
flask-migrate = "*"
flask-httpauth = "*"
redis = "*"
boto3 = "*"
celery = "*"
flask-cors = "*"
flask-mail = "*"
flask-allows = "*"
munch = "*"
simplejson = "*"
sentry-sdk = {extras = ["flask"],version = "*"}
requests = "*"
flask-pusher = "*"
pytest = "*"
flask-apispec = "*"
apispec = "*"
[requires]
python_version = "3.8"
和Pipfile.lock
:
{
"_meta": {
"hash": {
"sha256": "0c7064b1a043d3052854244fdfa5f817908c2917d80ce2bf215aaddceb10da4a"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"alembic": {
"hashes": [
],
"index": "pypi",
"version": "==1.5.7"
},
"amqp": {
"hashes": [
],
"markers": "python_version >= '3.6'",
"version": "==5.0.5"
},
"aniso8601": {
"hashes": [
],
"version": "==9.0.1"
},
"apispec": {
"hashes": [
],
"index": "pypi",
"version": "==4.3.0"
},
"attrs": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.3.0"
},
"billiard": {
"hashes": [
],
"version": "==3.6.3.0"
},
"blinker": {
"hashes": [
],
"version": "==1.4"
},
"boto3": {
"hashes": [
],
"index": "pypi",
"version": "==1.17.25"
},
"botocore": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
"version": "==1.20.25"
},
"celery": {
"hashes": [
],
"index": "pypi",
"version": "==5.0.5"
},
"certifi": {
"hashes": [
],
"version": "==2020.12.5"
},
"cffi": {
"hashes": [
],
"version": "==1.14.5"
},
"chardet": {
"hashes": [
"sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa",
"sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==4.0.0"
},
"click": {
"hashes": [
"sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a",
"sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==7.1.2"
},
"click-didyoumean": {
"hashes": [
"sha256:112229485c9704ff51362fe34b2d4f0b12fc71cc20f6d2b3afabed4b8bfa6aeb"
],
"version": "==0.0.3"
},
"click-plugins": {
"hashes": [
"sha256:46ab999744a9d831159c3411bb0c79346d94a444df9a3a3742e9ed63645f264b",
"sha256:5d262006d3222f5057fd81e1623d4443e41dcda5dc815c06b442aa3c02889fc8"
],
"version": "==1.1.1"
},
"click-repl": {
"hashes": [
"sha256:9c4c3d022789cae912aad8a3f5e1d7c2cdd016ee1225b5212ad3e8691563cda5",
"sha256:b9f29d52abc4d6059f8e276132a111ab8d94980afe6a5432b9d996544afa95d5"
],
"version": "==0.1.6"
},
"cryptography": {
"hashes": [
"sha256:066bc53f052dfeda2f2d7c195cf16fb3e5ff13e1b6b7415b468514b40b381a5b",
"sha256:0923ba600d00718d63a3976f23cab19aef10c1765038945628cd9be047ad0336",
"sha256:2d32223e5b0ee02943f32b19245b61a62db83a882f0e76cc564e1cec60d48f87",
"sha256:4169a27b818de4a1860720108b55a2801f32b6ae79e7f99c00d79f2a2822eeb7",
"sha256:57ad77d32917bc55299b16d3b996ffa42a1c73c6cfa829b14043c561288d2799",
"sha256:5ecf2bcb34d17415e89b546dbb44e73080f747e504273e4d4987630493cded1b",
"sha256:600cf9bfe75e96d965509a4c0b2b183f74a4fa6f5331dcb40fb7b77b7c2484df",
"sha256:66b57a9ca4b3221d51b237094b0303843b914b7d5afd4349970bb26518e350b0",
"sha256:93cfe5b7ff006de13e1e89830810ecbd014791b042cbe5eec253be11ac2b28f3",
"sha256:9e98b452132963678e3ac6c73f7010fe53adf72209a32854d55690acac3f6724",
"sha256:df186fcbf86dc1ce56305becb8434e4b6b7504bc724b71ad7a3239e0c9d14ef2",
"sha256:fec7fb46b10da10d9e1d078d1ff8ed9e05ae14f431fdbd11145edd0550b9a964"
],
"markers": "python_version >= '3.6'",
"version": "==3.4.6"
},
"flask": {
"hashes": [
"sha256:4efa1ae2d7c9865af48986de8aeb8504bf32c7f3d6fdc9353d34b21f4b127060",
"sha256:8a4fdd8936eba2512e9c85df320a37e694c93945b33ef33c89946a340a238557"
],
"index": "pypi",
"version": "==1.1.2"
},
"flask-allows": {
"hashes": [
"sha256:c6760e9ef6692cfbae8d50d4c16b987618301bc7ddc55b7667e1bc9cf3287aa0",
"sha256:d30304801536c20e903605697a013de7106e02f2ab61c7243318f7a98980c044"
],
"index": "pypi",
"version": "==0.7.1"
},
"flask-apispec": {
"hashes": [
"sha256:7e82dabcac4234c1540438daac045e8475804b4dcf7f68898ffc47113ab34da0",
"sha256:89e05dd2cb6e91ad999033c59aed4b5036aea9f0794d5ea5d9082be8ad4a99f2"
],
"index": "pypi",
"version": "==0.11.0"
},
"flask-cors": {
"hashes": [
"sha256:74efc975af1194fc7891ff5cd85b0f7478be4f7f59fe158102e91abb72bb4438",
"sha256:b60839393f3b84a0f3746f6cdca56c1ad7426aa738b70d6c61375857823181de"
],
"index": "pypi",
"version": "==3.0.10"
},
"flask-httpauth": {
"hashes": [
"sha256:3fcedb99a03985915335a38c35bfee6765cbd66d7f46440fa3b42ae94a90fac7",
"sha256:8c7e49e53ce7dc14e66fe39b9334e4b7ceb8d0b99a6ba1c3562bb528ef9da84a"
],
"index": "pypi",
"version": "==4.2.0"
},
"flask-jsonpify": {
"hashes": [
"sha256:8ac4c732aa5b11d9f6c2de58065d3b669f139518ca8f529bce943817e2fedbfb"
],
"version": "==1.5.0"
},
"flask-mail": {
"hashes": [
"sha256:22e5eb9a940bf407bcf30410ecc3708f3c56cc44b29c34e1726fe85006935f41"
],
"index": "pypi",
"version": "==0.9.1"
},
"flask-marshmallow": {
"hashes": [
"sha256:2adcd782b5a4a6c5ae3c96701f320d8ca6997995a52b2661093c56cc3ed24754",
"sha256:bd01a6372cbe50e36f205cfff0fc5dab0b7b662c4c8b2c4fc06a3151b2950950"
],
"index": "pypi",
"version": "==0.14.0"
},
"flask-migrate": {
"hashes": [
"sha256:26871836a4e46d2d590cf8e558c6d60039e1c003079b240689d845726b6b57c0",
"sha256:ae2f05671588762dd83a21d8b18c51fe355e86783e24594995ff8d7380dffe38"
],
"index": "pypi",
"version": "==2.7.0"
},
"flask-pusher": {
"hashes": [
"sha256:37b60c86e698068b148042f55f03b6d50254df6a9a85af115b4d47c2913b5795"
],
"index": "pypi",
"version": "==3.0"
},
"flask-restful": {
"hashes": [
"sha256:5ea9a5991abf2cb69b4aac19793faac6c032300505b325687d7c305ffaa76915",
"sha256:d891118b951921f1cec80cabb4db98ea6058a35e6404788f9e70d5b243813ec2"
],
"index": "pypi",
"version": "==0.3.8"
},
"flask-sqlalchemy": {
"hashes": [
"sha256:05b31d2034dd3f2a685cbbae4cfc4ed906b2a733cff7964ada450fd5e462b84e",
"sha256:bfc7150eaf809b1c283879302f04c42791136060c6eeb12c0c6674fb1291fae5"
],
"index": "pypi",
"version": "==2.4.4"
},
"idna": {
"hashes": [
"sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
"sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.10"
},
"iniconfig": {
"hashes": [
"sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3",
"sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"
],
"version": "==1.1.1"
},
"itsdangerous": {
"hashes": [
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
"sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.1.0"
},
"jinja2": {
"hashes": [
"sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419",
"sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==2.11.3"
},
"jmespath": {
"hashes": [
"sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9",
"sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.10.0"
},
"kombu": {
"hashes": [
"sha256:6dc509178ac4269b0e66ab4881f70a2035c33d3a622e20585f965986a5182006",
"sha256:f4965fba0a4718d47d470beeb5d6446e3357a62402b16c510b6a2f251e05ac3c"
],
"markers": "python_version >= '3.6'",
"version": "==5.0.2"
},
"mako": {
"hashes": [
"sha256:17831f0b7087c313c0ffae2bcbbd3c1d5ba9eeac9c38f2eb7b50e8c99fe9d5ab",
"sha256:aea166356da44b9b830c8023cd9b557fa856bd8b4035d6de771ca027dfc5cc6e"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.1.4"
},
"markupsafe": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.1.1"
},
"marshmallow": {
"hashes": [
],
"index": "pypi",
"version": "==3.10.0"
},
"marshmallow-sqlalchemy": {
"hashes": [
],
"index": "pypi",
"version": "==0.24.2"
},
"munch": {
"hashes": [
],
"index": "pypi",
"version": "==2.5.0"
},
"ndg-httpsclient": {
"hashes": [
],
"version": "==0.5.1"
},
"packaging": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.9"
},
"pluggy": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.13.1"
},
"prompt-toolkit": {
"hashes": [
],
"markers": "python_full_version >= '3.6.1'",
"version": "==3.0.17"
},
"psycopg2": {
"hashes": [
],
"index": "pypi",
"version": "==2.8.6"
},
"pusher": {
"hashes": [
],
"version": "==2.1.4"
},
"py": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.10.0"
},
"pyasn1": {
"hashes": [
],
"version": "==0.4.8"
},
"pycparser": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.20"
},
"pynacl": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.4.0"
},
"pyopenssl": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==20.0.1"
},
"pyparsing": {
"hashes": [
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.4.7"
},
"pytest": {
"hashes": [
],
"index": "pypi",
"version": "==6.2.2"
},
"python-dateutil": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.8.1"
},
"python-dotenv": {
"hashes": [
],
"index": "pypi",
"version": "==0.15.0"
},
"python-editor": {
"hashes": [
],
"version": "==1.0.4"
},
"pytz": {
"hashes": [
],
"version": "==2021.1"
},
"redis": {
"hashes": [
],
"index": "pypi",
"version": "==3.5.3"
},
"requests": {
"hashes": [
],
"index": "pypi",
"version": "==2.25.1"
},
"s3transfer": {
"hashes": [
],
"version": "==0.3.4"
},
"sentry-sdk": {
"extras": [
"flask"
],
"hashes": [
],
"index": "pypi",
"version": "==1.0.0"
},
"simplejson": {
"hashes": [
],
"index": "pypi",
"version": "==3.17.2"
},
"six": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.15.0"
},
"sqlalchemy": {
"hashes": [
],
"index": "pypi",
"version": "==1.3.23"
},
"toml": {
"hashes": [
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.10.2"
},
"urllib3": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
"version": "==1.26.3"
},
"vine": {
"hashes": [
],
"markers": "python_version >= '3.6'",
"version": "==5.0.0"
},
"wcwidth": {
"hashes": [
],
"version": "==0.2.5"
},
"webargs": {
"hashes": [
],
"markers": "python_version >= '3.6'",
"version": "==7.0.1"
},
"werkzeug": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==1.0.1"
}
},
"develop": {
"attrs": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.3.0"
},
"flake8": {
"hashes": [
],
"index": "pypi",
"version": "==3.8.4"
},
"iniconfig": {
"hashes": [
],
"version": "==1.1.1"
},
"mccabe": {
"hashes": [
],
"version": "==0.6.1"
},
"mypy": {
"hashes": [
],
"index": "pypi",
"version": "==0.812"
},
"mypy-extensions": {
"hashes": [
],
"version": "==0.4.3"
},
"packaging": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.9"
},
"pluggy": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.13.1"
},
"py": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.10.0"
},
"pycodestyle": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.6.0"
},
"pyflakes": {
"hashes": [
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.2.0"
},
"pyparsing": {
"hashes": [
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.4.7"
},
"pytest": {
"hashes": [
],
"index": "pypi",
"version": "==6.2.2"
},
"toml": {
"hashes": [
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.10.2"
},
"typed-ast": {
"hashes": [
...
],
"version": "==1.4.2"
},
"typing-extensions": {
"hashes": [
...
],
"version": "==3.7.4.3"
}
}
}
现在我需要添加 weasyprint 包,所以我输入:
$ pipenv install weasyprint
它安装但烧瓶抛出:
ModuleNotFoundError: No module named 'flask._compat'
因为 Flask 设置为==2.0.1
而不是"==1.1.2"
. 所以我设置并运行它对(大多数与 Flask 相关的软件包保持在默认(安装之前)版本flask = "==1.1.2"
中)进行了较少的更改,但现在我得到以下信息:Pipfile
pipenv install
Pipfile.lock
weasyprint
File "/home/al/python/project/.venv/lib/python3.8/site-packages/flask/json/__init__.py", line 211, in dumps
rv = _json.dumps(obj, **kwargs)
File "/usr/lib/python3.8/json/__init__.py", line 234, in dumps
return cls(
File "/usr/lib/python3.8/json/encoder.py", line 201, in encode
chunks = list(chunks)
File "/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.8/json/encoder.py", line 325, in _iterencode_list
yield from chunks
File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
o = _default(o)
File "/home/al/python/project/.venv/lib/python3.8/site-packages/flask/json/__init__.py", line 100, in default
return _json.JSONEncoder.default(self, o)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Decimal is not JSON serializable
flask's
jsonify
为从数据库中获取的相同数据调用函数。所以我不明白:
- 我应该修改我的源代码以实现处理
decimals
吗?如果是这样,不明白它以前是如何以及为什么起作用的?或者 - 我是否应该尝试获得正确的设置包版本(如果可以,我该怎么做)?尝试为 Pipfile 中的每个包(取自原始 Pipfile.lock 的版本)设置某些包版本(不确定在生产中使用 Flask 的情况下是否正确) - 错误仍然存在。
- 在生产中使用的基于烧瓶的应用程序中处理修订的正确方法是什么?
例如,我担心 Pipfile 过于大胆地解析软件包版本。