No module named PIL in heroku though it is installed

时间秒杀一切 提交于 2019-12-02 21:46:08

问题


I have been trying to deploy a Django application on Heroku.

Some background - I hadn't used virtual environment while building the application but while deploying it, I had to use it. I'm following this tutorial for deployment. https://medium.com/agatha-codes/9-straightforward-steps-for-deploying-your-django-app-with-heroku-82b952652fb4 Now I'm stuck in step-6. After creating a virtual environment I have freezed the dependencies into requirements.txt.

But when I open the deployed URL it says

ImportError at /
No module named PIL

though Pillow has been installed, it is there in requirements.txt and runs fine when hosted on a local server.

This is my requirements.txt.

certifi==2018.4.16
dj-database-url==0.5.0
Django==1.11.14
django-heroku==0.3.1
gunicorn==19.9.0
packaging==17.1
Pillow==5.2.0
pip-review==1.0
pipenv==2018.7.1
pkg-resources==0.0.0
psycopg2==2.7.5
pyparsing==2.2.0
pytz==2018.5
six==1.11.0
virtualenv==16.0.0
virtualenv-clone==0.3.0
whitenoise==3.3.1

Please help me with this.


回答1:


If you are doing this in your view

import PIL

do this

import Image



回答2:


Heroku? Access your application and manually run pip install -r requirements.txt, then turn the application off and back on again.

I had this problem before, this step solved my problem.



来源:https://stackoverflow.com/questions/51188975/no-module-named-pil-in-heroku-though-it-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!