简体   繁体   中英

Installing PIL on heroku instance

I have created a python-flask application which is hosted on heroku.I amusing PIL imaging library in python. I could not install PIL in heroku instance.

I have tried the following ways.

method 1:

Added PIL=1.1.7 in requirements.txt here I got exception

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

method 2:

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

This helped to install the PIL I got the successfully installed message. Successfully installed PIL Cleaning up... But, after I pushed my latest code I have got the import error for PIL . I have attached the log files below by the command 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=

method 3:

Even I had tried to import the PIL python module as part of my application, like the third party module which shows that imaging C library not installed

Could you please help me on installing PIL in heroku instance?

To install Pillow and other libraries with C dependencies, one option is use the conda buildpack. Heroku suggests it in their documentation here: Python C Dependencies The buildpack is available here .

The documentation provides two steps for doing this.

  1. Separate libraries with C dependencies into a conda-requirements.txt file. In this case, move Pillow from requirements.txt to conda-requirements.txt.
  2. Use the conda build pack when creating the application.

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

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

    If this is to be used with an existing application, use the following instead.

    heroku config:add BUILDPACK_URL= https://github.com/kennethreitz/conda-buildpack.git

Once these steps are completed, the application can be deployed as normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM