当我像这样运行mypy
时:
mypy file.py
它给我抛出一个错误Variable annotation syntax is only supported in Python 3.6 and greater
。好的,我试图这样运行它:
python3.6 -m mypy file.py
但是它给出了The typed_ast package is not installed
。好的,我用sudo pip3 install typed_ast --target=/usr/lib/python3.6 --upgrade
安装了它。之后,我检查了要安装的软件包:
sanyash@sanyash-ub16:~/myrepos/trash$ python3.6
Python 3.6.6 (default, Jun 28 2018, 04:42:43)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import typed_ast
>>> Ok, no import error
但是命令python3.6 -m mypy file.py
仍然失败,并显示The typed_ast package is not installed
。为什么?我该如何解决?通常,我可以使用python3.6运行mypy
吗?