问题描述
我有一个使用Spacy模型"en_core_web_sm"的应用.我已经在本地计算机上测试了该应用程序,并且运行正常.
I have an app that uses the Spacy model "en_core_web_sm". I have tested the app on my local machine and it works fine.
但是,当我将其部署到Heroku时,会出现此错误:
However when I deploy it to Heroku, it gives me this error:
找不到模型'en_core_web_sm'.它似乎不是快捷方式链接,Python软件包或数据目录的有效路径."
"Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory."
我的需求文件包含spacy == 2.2.4.
My requirements file contains spacy==2.2.4.
我一直在研究此错误,发现需要使用以下命令单独下载模型:python -m spacy download en_core_web_sm
I have been doing some research on this error and found that the model needs to be downloaded separately using this command:python -m spacy download en_core_web_sm
我一直在寻找将相同内容添加到我的requirements.txt文件中的方法,但一直没找到有效的方法!
I have been looking for ways to add the same to my requirements.txt file but haven't been able to find one that works!
我也尝试过-将以下内容添加到需求文件中:
I tried this as well - added the below to the requirements file:
-e git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz#egg=en_core_web_sm==2.2.0
但是它给出了这个错误:
but it gave this error:
将git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz克隆到/app/.heroku/src/en-core -web-sm
"Cloning git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz to /app/.heroku/src/en-core-web-sm
运行命令git clone -q git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz/app/.heroku/src/核心网络短信致命:远程错误: 爆炸/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz不是有效的存储库名称.
Running command git clone -q git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz /app/.heroku/src/en-core-web-smfatal: remote error: explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz is not a valid repository name"
是否有一种方法可以从需求文件中加载此Spacy模型?或任何其他可能的修复方法?
Is there a way to get this Spacy model to load from the requirements file? Or any other fix that is possible?
谢谢.
推荐答案
好,所以经过更多谷歌搜索并寻求解决方案后,我发现此解决方案有效:
Ok, so after some more Googling and hunting for a solution, I found this solution that worked:
我从@tausif在他的答案中共享的URL中下载了tarball到我的本地系统.
I downloaded the tarball from the url that @tausif shared in his answer, to my local system.
将其保存在具有我的requirements.txt文件的目录中.
Saved it in the directory which had my requirements.txt file.
然后我将此行添加到我的requirements.txt文件中:./en_core_web_sm-2.2.5.tar.gz
Then I added this line to my requirements.txt file: ./en_core_web_sm-2.2.5.tar.gz
继续部署到Heroku-成功,并且该应用程序现在可以完美运行.
Proceeded with deploying to Heroku - it succeeded and the app works perfectly now.
这篇关于如何将Spacy模型添加到requirements.txt文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!