尝试上传字段时出现错误n heroku:
ModuleNotFoundError
没有名为“ PIL”的模块
完整追溯:
2018-08-16T01:12:18.364616+00:00 app[web.1]: Internal Server Error: /admin/app/neighborhood/add/
2018-08-16T01:12:18.364628+00:00 app[web.1]: Traceback (most recent call last):
2018-08-16T01:12:18.364630+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2018-08-16T01:12:18.364632+00:00 app[web.1]: response = get_response(request)
2018-08-16T01:12:18.364634+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
2018-08-16T01:12:18.364635+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request)
2018-08-16T01:12:18.364637+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
2018-08-16T01:12:18.364639+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2018-08-16T01:12:18.364641+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py", line 607, in wrapper
2018-08-16T01:12:18.364642+00:00 app[web.1]: return self.admin_site.admin_view(view)(*args, **kwargs)
2018-08-16T01:12:18.364644+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
2018-08-16T01:12:18.364646+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2018-08-16T01:12:18.364647+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
2018-08-16T01:12:18.364649+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2018-08-16T01:12:18.364651+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 223, in inner
2018-08-16T01:12:18.364653+00:00 app[web.1]: return view(request, *args, **kwargs)
2018-08-16T01:12:18.364654+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1647, in add_view
2018-08-16T01:12:18.364656+00:00 app[web.1]: return self.changeform_view(request, None, form_url, extra_context)
2018-08-16T01:12:18.364657+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py", line 45, in _wrapper
2018-08-16T01:12:18.364659+00:00 app[web.1]: return bound_method(*args, **kwargs)
2018-08-16T01:12:18.364660+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
2018-08-16T01:12:18.364662+00:00 app[web.1]: response = view_func(request, *args, **kwargs)
2018-08-16T01:12:18.364664+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1536, in changeform_view
2018-08-16T01:12:18.364665+00:00 app[web.1]: return self._changeform_view(request, object_id, form_url, extra_context)
2018-08-16T01:12:18.364667+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1568, in _changeform_view
2018-08-16T01:12:18.364668+00:00 app[web.1]: form_validated = form.is_valid()
2018-08-16T01:12:18.364670+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/forms.py", line 185, in is_valid
2018-08-16T01:12:18.364672+00:00 app[web.1]: return self.is_bound and not self.errors
2018-08-16T01:12:18.364673+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/forms.py", line 180, in errors
2018-08-16T01:12:18.364675+00:00 app[web.1]: self.full_clean()
2018-08-16T01:12:18.364677+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/forms.py", line 381, in full_clean
2018-08-16T01:12:18.364678+00:00 app[web.1]: self._clean_fields()
2018-08-16T01:12:18.364699+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/forms.py", line 397, in _clean_fields
2018-08-16T01:12:18.364701+00:00 app[web.1]: value = field.clean(value, initial)
2018-08-16T01:12:18.364703+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/fields.py", line 586, in clean
2018-08-16T01:12:18.364705+00:00 app[web.1]: return super().clean(data)
2018-08-16T01:12:18.364706+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/fields.py", line 147, in clean
2018-08-16T01:12:18.364708+00:00 app[web.1]: value = self.to_python(value)
2018-08-16T01:12:18.364709+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/forms/fields.py", line 615, in to_python
2018-08-16T01:12:18.364711+00:00 app[web.1]: from PIL import Image
2018-08-16T01:12:18.364719+00:00 app[web.1]: ModuleNotFoundError: No module named 'PIL'
第613行of this django code is where the import of PIL is
我可以进入heroku bash并将其导入(我想它没有安装)
aiden@aiden-home:~/Desktop/dcre$ heroku run bash
› Warning: heroku update available from 7.7.4 to 7.7.10
Running bash on ⬢ protected-dusk-26749... up, run.3330 (Free)
~ $ python3
Python 3.6.6 (default, Aug 1 2018, 21:10:27)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PIL'
>>> quit()
~ $ pip3 list
Package Version
---------------- ---------
certifi 2018.8.13
dj-database-url 0.5.0
Django 2.1
django-heroku 0.3.1
gunicorn 19.9.0
pip 18.0
pipenv 2018.5.18
psycopg2 2.7.5
psycopg2-binary 2.7.5
pytz 2018.5
setuptools 40.0.0
virtualenv 16.0.0
virtualenv-clone 0.3.0
wheel 0.31.1
whitenoise 4.0
~ $ pip3 install Pillow
Collecting Pillow
Downloading https://files.pythonhosted.org/packages/d1/24/f53ff6b61b3d728b90934bddb4f03f8ab584a7f49299bf3bde56e2952612/Pillow-5.2.0-cp36-cp36m-manylinux1_x86_64.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 8.0MB/s
Installing collected packages: Pillow
Successfully installed Pillow-5.2.0
~ $ python3
Python 3.6.6 (default, Aug 1 2018, 21:10:27)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> quit()
所以我做些事情,我“重新启动所有测功机”,然后尝试再次上传图像。同样的错误
所以我退出heroku bash,重新输入并
aiden@aiden-home:~/Desktop/dcre$ heroku run bash
› Warning: heroku update available from 7.7.4 to 7.7.10
Running bash on ⬢ protected-dusk-26749... up, run.3115 (Free)
~ $ pip3 list
Package Version
---------------- ---------
certifi 2018.8.13
dj-database-url 0.5.0
Django 2.1
django-heroku 0.3.1
gunicorn 19.9.0
pip 18.0
pipenv 2018.5.18
psycopg2 2.7.5
psycopg2-binary 2.7.5
pytz 2018.5
setuptools 40.0.0
virtualenv 16.0.0
virtualenv-clone 0.3.0
wheel 0.31.1
whitenoise 4.0
我的枕头已以某种方式被卸载。为什么会这样
答案 0 :(得分:1)
我实际上才发现-我正在使用heroku-django-template,它具有一个Pipfile(新的抽录方式),b / c Pillow不在我的Pipfile中,每次我重新启动heroku时,它都会擦除。我在Pipfile中添加了Pillow =“ *”并可以正常使用