github - 在 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
任何建议将不胜感激,我很乐意添加更多信息。
解决方案
尝试添加lxml
到您的requirements.txt
.
推荐阅读
- python - python中某些字符类型的最长连续子字符串
- javascript - 使用 webpack [request] 魔术注释将动态模块捆绑在一起
- python - 如何在由第二列定义的固定间隔内对一列的元素求和?
- flutter - Flutter 中如何渲染字体或者如何避免垂直间距?
- python - 在 Python 中导入时未解析的引用
- laravel - Laravel 5.7 Testing with Passport in seeder
- python - 基于标签而不是绝对位置在 XML 中查找值
- exchange-server - 使用 Exchange 和 SonicWall 配置 HA 代理
- laravel - Laravel:更改密码路径中的 MethodNotAllowedHttpException 错误
- python - 通过 Celery 中的参数获取正在运行的工作者