Python 当NLTK";“朋克”;需要

Python 当NLTK";“朋克”;需要,python,continuous-integration,nltk,github-actions,building-github-actions,Python,Continuous Integration,Nltk,Github Actions,Building Github Actions,我已经编写了一些需要使用NLTK的punkt的代码。我已将nltk包含在requirements.txt和setup.py中。但是,当我使用GitHub操作运行项目的构建时,它会失败并出现此错误 E LookupError: E ********************************************************************** E Resource punkt not found. E

我已经编写了一些需要使用NLTK的punkt的代码。我已将
nltk
包含在
requirements.txt
setup.py
中。但是,当我使用GitHub操作运行项目的构建时,它会失败并出现此错误

E       LookupError:   
E       **********************************************************************  
E         Resource punkt not found.  
E         Please use the NLTK Downloader to obtain the resource:  
E       
E         >>> import nltk  
E         >>> nltk.download('punkt') 
告诉GitHub操作它需要
'punkt'
而不需要硬编码
nltk的标准方法是什么?下载('punkt')

我应该在
ci.yml
文件中添加一行吗?最好的方法是什么?

ci.yml
文件中,在导入
requirements.txt
中定义的依赖项后添加
nltk.downloader
命令行对我来说很有效

if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m nltk.downloader punkt stopwords

我找到了一种解决方法,在使用pytest运行测试之前,在
ci.yml
中添加
echo-e“import-nltk\nnltk.download('punkt')”| python3
。但是,任何更优雅的解决方案都是非常受欢迎的。尝试创建nltk.txt文件,并包括
punkt
?还使用了andrea提出的
ci.yml
更改。似乎在工作:D