annotations导入报错
相关环境版本
1 | python 3.7.10 |
报错文件
1 | # main.py |
报错信息
1.
1 | main.py:1:23: future feature annotations is not defined |
1 | Traceback (most recent call last): |
报错原因
- 使用Cython版本过低
https://github.com/cython/cython/issues/2950#issuecomment-679136993
- 使用python3.7以下版本
报错: https://stackoverflow.com/questions/52889746/cant-import-annotations-from-future/52890129
根据PEP-563在py3.7中才能使用
https://www.python.org/dev/peps/pep-0563/#enabling-the-future-behavior-in-python-3-7
报错解决
1.升级Cython, 使用3.0版本
1 | pip3.7 install Cython==3.0a1 |
2.使用python3.7以上版本
相关链接
https://github.com/cython/cython/issues/2950
https://stackoverflow.com/questions/52889746/cant-import-annotations-from-future/52890129
https://www.python.org/dev/peps/pep-0563/#enabling-the-future-behavior-in-python-3-7

作者:
胖胖不胖
版权声明:
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 不止于python
感谢您的支持,我会继续努力!
微信支付
支付宝