gpt4 book ai didi

导入库时 Python StanfordNLP 包错误

转载 作者:太空宇宙 更新时间:2023-11-04 04:15:14 25 4
gpt4 key购买 nike

我刚刚安装了 python stanford nlp,运行良好:-

pip 安装 stanfordnlp

我在 python shell 中尝试实例化包,但出现以下错误:-

>>> import stanfordnlp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/__init__.py", line 1, in <module>
from stanfordnlp.pipeline.core import Pipeline
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/pipeline/core.py", line 9, in <module>
from stanfordnlp.pipeline.doc import Document
File "/Users/shivajidutta/anaconda/lib/python2.7/site-packages/stanfordnlp/pipeline/doc.py", line 175
return f"<{self.__class__.__name__} index={self.index};words={self.words}>"
^
SyntaxError: invalid syntax

最佳答案

行:

return f"<{self.__class__.__name__} index={self.index};words={self.words}>"

表示该包适用于 Python 3.6 或更高版本。它返回一个 f 字符串,这是在 3.6 版中引入的。您正在运行 2.7 版。

是时候升级了吗?

关于导入库时 Python StanfordNLP 包错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55583739/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com