首页 > 解决方案 > 在 heroku 应用程序上使用 Beautiful Soup

问题描述

我正在尝试使用以下库部署我在 Python 中制作的机器人:requests、beautifulsoup4、discord。

这将使用我相信 git hub 和 Heroku 进行部署。机器人部署成功;但是,当我检查日志时,机器人已经崩溃。这是错误消息:

2020-05-17T23:17:42.624634+00:00 app[api]: Deploy 83c32a30 by user ****************************
2020-05-17T23:17:42.624634+00:00 app[api]: Release v12 created by user ****************************
2
2020-05-17T23:17:43.134443+00:00 heroku[worker.1]: State changed from crashed to starting
2020-05-17T23:17:48.338694+00:00 heroku[worker.1]: State changed from starting to up
2020-05-17T23:17:51.764352+00:00 heroku[worker.1]: State changed from up to crashed
2020-05-17T23:17:51.660991+00:00 app[worker.1]: Traceback (most recent call last):
2020-05-17T23:17:51.661016+00:00 app[worker.1]: File "BocoBot_Version1.py", line 126, in <module>
2020-05-17T23:17:51.661182+00:00 app[worker.1]: soup = BeautifulSoup(source, 'lxml')
2020-05-17T23:17:51.661184+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/bs4/__init__.py", line 245, in __init__
2020-05-17T23:17:51.661401+00:00 app[worker.1]: % ",".join(features))
**2020-05-17T23:17:51.661423+00:00 app[worker.1]: bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?**
2020-05-17T23:17:57.000000+00:00 app[api]: Build succeeded

我相信这是有问题的问题:

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

但我不知道我需要做什么来解决它。我的猜测是它与我的 requirements.txt 文件有关,我告诉它要添加哪些包。但无论我对 BeautifulSoup4 进行什么更改,它仍然无法正常工作。

这是 requirements.txt 文件信息:

git+https://github.com/Rapptz/discord.py
PyNaCl==1.3.0
pandas
beautifulsoup4
requests
discord
dnspython==1.16.0
async-timeout==3.0.1

任何建议将不胜感激,我很乐意添加更多信息。

标签: githubherokubeautifulsoupdiscord

解决方案


尝试添加lxml到您的requirements.txt.


推荐阅读