Albumy:ImportError: cannot import name ‘TimedJSONWebSignatureSerializer’ from ‘itsdangerous’

按照书本内容依次clone、pipenv install -dev、pipenv shell、flask forge后,出现了“Exception: Install ‘email_validator’ for email validation support.”的问题。

使用pipenv install email_validator后又出现:

"ImportError: cannot import name ‘TimedJSONWebSignatureSerializer’ from ‘itsdangerous’ (C:\Users\Administrator.virtualenvs\albumy-PUGH3OL4\lib\site-packages\itsdangerous_init_.py)
Usage: flask [OPTIONS] COMMAND [ARGS]…
Try ‘flask --help’ for help.
Error: No such command ‘forge’.

未对源码进行任何修改。请问该如何解决?

从报错看是因为没有安装指定的依赖版本。试试用 pip 来安装呢?

Windows:

> python -m venv venv
> venv\Scripts\activate
> pip install -r requirements.txt

macOS/Linux:

$ python3 -m venv venv
$ source venv/bin/activate 
$ pip install -r requirements.txt

替代方法是安装 1.1.1 版本的 ItsDangerous:

$ pipenv install itsdangerous==1.1.0

$ pip install itsdangerous==1.1.0