from __future__ import annotations
SyntaxError: future feature annotations is not defined
当我尝试在VSCode终端中运行我的代码时出现此错误。当我使用PyCharm运行代码时,我从未遇到此错误。我只是不明白是什么让它在VSCode中无法正常工作。
我使用Python 3.7作为我的项目解释器。
除非您创建了一个虚拟环境并选择了它作为您的解释器,否则输入类似python3 myfile.py
的内容并不能保证您使用的是在VS Code中选择的Python解释器(在您的shell的控制下,而不是VS Code)。确保使用Run Python File in Terminal
,以确保您的文件使用选定的Python解释器运行。