【问题标题】:SyntaxError: future feature annotations is not defined [duplicate]SyntaxError:未定义未来的功能注释[重复]
【发布时间】:2021-12-29 04:40:04
【问题描述】:

我正在尝试运行代码

sh run.sh

它向我显示了错误

File "/anaconda3/envs/_galaxy_/lib/python3.6/site-packages/filelock/__init__.py", line 8
    from __future__ import annotations
    ^
SyntaxError: future feature annotations is not defined

我看到一些解决方案表明我需要更新我的 python 版本,但我使用的是 python 版本 3.9.7。

(py39) KedeMacBook-Pro:~ ke$ python --version
Python 3.9.7

但是,在错误代码中,它显示了 3.6 的 python 版本。所以,我不确定哪里出错了。为什么它不使用我拥有的 python 环境?请帮忙,谢谢。

【问题讨论】:

标签: python conda


【解决方案1】:

根据错误,您的代码似乎使用的是 Python 3.6 而不是 Python 3.9。从 Python 3.7 开始可以使用此导入。检查run.sh 以确保它引用了正确的python 解释器。

我还建议使用virtual env,使用您需要的 python 版本并在其中运行您的脚本。

【讨论】:

  • 非常感谢,在我创建了 virtualenv 之后它就起作用了。这个错误困扰了我好几个星期,谢谢你拯救了我的一天。哈哈
  • @keee 没问题 :)
猜你喜欢
  • 2020-09-22
  • 2021-03-05
  • 2014-07-21
  • 1970-01-01
  • 2015-09-30
  • 1970-01-01
  • 2016-07-17
  • 2022-12-16
相关资源
最近更新 更多