我使用 Rasa NLU 和 Rasa Core 制作了一个机器人。它连接到 Node.js 服务器和 React.js 前端。我运行这个 python 脚本的方式是:
var PythonShell = require('python-shell');
var options = {
mode: 'text',
pythonOptions: ['-u'],
scriptPath: './server/Rasa_Bot_Final'
};
var pyshell = new PythonShell('dialogue_management_model.py', options);
app.post('/message', (req, res) => {
pyshell.on('message', function (message) {
// received a message sent from the Python script (a simple "print" statement)
res.end(message)
});
pyshell.send(req.body.messageFromUser);
})
这适用于我的本地主机,但是,当部署到 heroku 时,我收到此错误:
Error: OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
这是因为我无法运行:
python -m spacy download en_core_web_md
python -m spacy link en_core_web_md en
在 heroku 上。
有人可以帮我解决这个问题吗?
我引用了这些: https://spacy.io/usage/
最佳答案
确保在需求中添加了 spacy 和包含 python 命令的 Procfile。
在Procfile中:
web: python -m spacy download en_core_web_md && python -m spacy link en_core_web_md en
如果它来自无法运行 python 代码的事实,那么它可能来自无法识别您的代码并相应地设置所有内容的 dyno。
你应该检查一下,我认为这就是 heroku 调用的 buildpack .
关于python - 如何使用 Spacy 将 Rasa Bot 部署到 Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50934751/