【问题标题】:Installing PIL on heroku instance在 heroku 实例上安装 PIL
【发布时间】:2014-08-07 10:10:34
【问题描述】:

我创建了一个托管在heroku 上的python-flask 应用程序。我在python 中使用PIL 成像库。我无法在 heroku 实例中安装 PIL

我尝试了以下方法。

方法一:

requirements.txt 中添加了PIL=1.1.7 这里我有异常

Some externally hosted files were ignored (use --allow-external PIL to allow).

方法二:

heroku run pip install PIL --allow-unverified=PIL --app=nava-app

这有助于安装PIL 我收到了安装成功的消息。 Successfully installed PIL Cleaning up... 但是,在我推送我的最新代码后,我得到了import errorPIL。我已经通过命令heroku logs --app=nava-app 附加了下面的日志文件。

2014-08-07T09:54:28.997111+00:00 app[web.1]:     worker.init_process()
2014-08-07T09:54:28.997112+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
2014-08-07T09:54:28.997113+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2014-08-07T09:54:28.997115+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi
2014-08-07T09:54:28.997116+00:00 app[web.1]:     self.callable = self.load()
2014-08-07T09:54:28.997117+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 25, in load
2014-08-07T09:54:28.997118+00:00 app[web.1]:     return util.import_app(self.app_uri)
2014-08-07T09:54:28.997120+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 372, in import_app
2014-08-07T09:54:28.997121+00:00 app[web.1]:     __import__(module)
2014-08-07T09:54:28.997122+00:00 app[web.1]:   File "/app/app.py", line 5, in <module>
2014-08-07T09:54:28.997123+00:00 app[web.1]:     from test import draw
2014-08-07T09:54:28.997125+00:00 app[web.1]:   File "/app/test.py", line 10, in <module>
2014-08-07T09:54:28.997127+00:00 app[web.1]: ImportError: No module named PIL
2014-08-07T09:54:28.997126+00:00 app[web.1]:     from PIL import ImageFont
2014-08-07T09:54:28.997135+00:00 app[web.1]: 2014-08-07 09:54:28 [7] [INFO] Worker exiting (pid: 7)
2014-08-07T09:54:29.421102+00:00 app[web.1]: 2014-08-07 09:54:29 [2] [INFO] Shutting down: Master
2014-08-07T09:54:29.421211+00:00 app[web.1]: 2014-08-07 09:54:29 [2] [INFO] Reason: Worker failed to boot.
2014-08-07T09:54:31.583231+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nava-app.herokuapp.com request_id=b1f72038-5c9c-4680-801e-8f6a87ab8829 fwd="103.6.158.181" dyno=web.1 connect=5000ms service= status=503 bytes=
2014-08-07T09:54:30.607109+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-07T09:54:27.580747+00:00 heroku[web.1]: Starting process with command `gunicorn app:app --log-file -`
2014-08-07T09:54:30.594821+00:00 heroku[web.1]: Process exited with status 3
2014-08-07T09:54:41.551284+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nava-app.herokuapp.com request_id=97b28fa4-e082-4887-8b5c-d088d006e569 fwd="103.6.158.181" dyno= connect= service= status=503 bytes=

方法3:

即使我曾尝试将 PIL python 模块作为我的应用程序的一部分导入,例如显示 imaging C library not installed 的第三方模块

您能帮我在 heroku 实例中安装 PIL 吗?

【问题讨论】:

标签: python heroku


【解决方案1】:

要安装 Pillow 和其他具有 C 依赖项的库,一种选择是使用 conda buildpack。 Heroku 在他们的文档中建议:Python C Dependencies buildpack 可用here

文档提供了执行此操作的两个步骤。

  1. 将具有 C 依赖项的库分离到 conda-requirements.txt 文件中。在这种情况下,请将 Pillow 从 requirements.txt 移动到 conda-requirements.txt。
  2. 在创建应用程序时使用 conda 构建包。

    heroku create --buildpack https://github.com/kennethreitz/conda-buildpack.git

    heroku create --buildpack https://github.com/kennethreitz/conda-buildpack.git

    如果要与现有应用程序一起使用,请改用以下内容。

    heroku 配置:添加 BUILDPACK_URL=https://github.com/kennethreitz/conda-buildpack.git

完成这些步骤后,即可正常部署应用程序。

【讨论】:

    猜你喜欢
    • 2014-09-03
    • 1970-01-01
    • 2018-05-24
    • 2014-04-15
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    • 1970-01-01
    相关资源
    最近更新 更多