【问题标题】:Deploying Flask app to Heroku: ModuleNotFoundError: No module named 'lxml'将 Flask 应用程序部署到 Heroku:ModuleNotFoundError: No module named 'lxml'
【发布时间】:2017-07-31 02:36:19
【问题描述】:

烧瓶在我的本地机器上运行良好。但是,当我尝试将其部署到 heroku 时,我陷入了部署步骤: git push heroku master

错误是: ModuleNotFoundError: No module named 'lxml'

谢谢!

看来heroku已经成功下载了lxml模块,我怀疑路径有问题。

Downloading lxml-3.8.0-cp36-cp36m-manylinux1_x86_64.whl (7.3MB)
remote:        Collecting tushare==0.8.2 (from -r /tmp/build_c53be87973e8917c338f0bc2fe032c48/requirements.txt (line 46))
remote:          

Downloading tushare-0.8.2.zip (121kB)
remote:            Complete output from command python setup.py egg_info:
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-build-a4xb2e0z/tushare/setup.py", line 4, in <module>
remote:                import tushare
remote:              File "/tmp/pip-build-a4xb2e0z/tushare/tushare/__init__.py", line 6, in <module>
remote:                from tushare.stock.trading import (get_hist_data, get_tick_data,
remote:              File "/tmp/pip-build-a4xb2e0z/tushare/tushare/stock/trading.py", line 13, in <module>
remote:                import lxml.html
remote:            ModuleNotFoundError: No module named 'lxml'

【问题讨论】:

  • 你能分享完整的终端输出吗?看起来您刚刚错过了将 lxml 添加到您的 requirements.txt
  • 你尝试安装 lxml 了吗?
  • sudo apt-get install python-lxml

标签: python-3.x heroku flask deployment


【解决方案1】:

现在解决了。

  1. 从requirement.txt中删除tushare,然后执行git commit -am "make it better"和git push heroku master,就会推送成功;

  2. 将 tushare 放回 requirements.txt,重做 git commit -am "make it better" 和 git push heroku master。

【讨论】:

  • 知道为什么会这样吗?即使我也面临同样的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-04
  • 1970-01-01
  • 2021-11-11
  • 2016-06-13
  • 1970-01-01
  • 2020-12-28
  • 1970-01-01
相关资源
最近更新 更多