使用Pipenv安装Flask-WTF及其依赖时,报错显示locking failed

使用命令pipenv install flask-wtf email-validator安装依赖,工作路径在 ~/Pycharmprojects/helloflask下
命令行输出如下:
@LAPTOP-U7U84LND MINGW64 ~/PycharmProjects/helloflask (master)
$ pipenv install flask-wtf email-validator
Installing flask-wtf…
Adding flask-wtf to Pipfile’s [packages]…
Installation Succeeded
Installing email-validator…
Adding email-validator to Pipfile’s [packages]…
Installation Succeeded
Pipfile.lock (733065) out of date, updating to (008abb)…
Locking [dev-packages] dependencies…
Locking…Building requirements…
Resolving dependencies…
[ ] Locking…Success!
Locking [packages] dependencies…
Locking…Building requirements…
Resolving dependencies…
[ =] Locking…Locking Failed!
[ResolutionFailure]: File “c:/users/lenovo/appdata/local/programs/python/python36/lib/site-packages/pipenv/resolver.py”, line 741, in _main
[ResolutionFailure]: resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]: File “c:/users/lenovo/appdata/local/programs/python/python36/lib/site-packages/pipenv/resolver.py”, line 709, in resolve_packages
[ResolutionFailure]: requirements_dir=requirements_dir,
[ResolutionFailure]: File “c:/users/lenovo/appdata/local/programs/python/python36/lib/site-packages/pipenv/resolver.py”, line 692, in resolve
[ResolutionFailure]: req_dir=requirements_dir
[ResolutionFailure]: File “c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages\pipenv\utils.py”, line 1403, in resolve_deps
[ResolutionFailure]: req_dir=req_dir,
[ResolutionFailure]: File “c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages\pipenv\utils.py”, line 1108, in actually_resolve_deps
[ResolutionFailure]: resolver.resolve()
[ResolutionFailure]: File “c:\users\lenovo\appdata\local\programs\python\python36\lib\site-packages\pipenv\utils.py”, line 833, in resolve
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Could not find a version that matches markupsafe==1.1.1,>=2.0 (from -r C:\Users\Lenovo\AppData\Local\Temp\pipenvz7yncar0requirements\pipenv-p7_v7t6j-constraints.txt (line 10))
Tried: 0.9, 0.9.1, 0.9.2, 0.9.3, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 1.0, 1.1.0, 1.1.0, 1.1.1, 1.1.1, 2.0.0, 2.0.0, 2.0.1, 2.0.1
Skipped pre-versions: 2.0.0a1, 2.0.0a1, 2.0.0rc1, 2.0.0rc1, 2.0.0rc2, 2.0.0rc2
There are incompatible versions in the resolved dependencies:
markupsafe==1.1.1 (from -r C:\Users\Lenovo\AppData\Local\Temp\pipenvz7yncar0requirements\pipenv-p7_v7t6j-constraints.txt (line 10))
markupsafe (from wtforms==2.3.3->flask-wtf==0.14.3->-r C:\Users\Lenovo\AppData\Local\Temp\pipenvz7yncar0requirements\pipenv-p7_v7t6j-constraints.txt (line 9))
markupsafe>=2.0 (from jinja2==3.0.1->flask==2.0.1->-r C:\Users\Lenovo\AppData\Local\Temp\pipenvz7yncar0requirements\pipenv-p7_v7t6j-constraints.txt (line 11))

看起来是某两个依赖需要的 MarkupSafe 版本发生了冲突。我建议先重新创建一个虚拟环境,然后只执行一次 pipenv install --dev,这会安装仓库里固定版本的所有依赖,不需要再单独安装,后续章节的安装命令只是示例。