在中使用Python进行部署后,我发现了运行容器的以下错误:
APP/PROC/WEB 0 File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "<frozen importlib._bootstrap_external>", line 678, in exec_module
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 callback, param_dict = resolver.resolve_error_handler(500)
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 141, in handle_uncaught_exception
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 103, in response_for_exception
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 response = response_for_exception(request, exc)
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 49, in inner
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 response = self._middleware_chain(request)
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in get_response
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 response = self.get_response(request)
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 respiter = self.wsgi(environ, resp.start_response)
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 self.handle_request(listener, req, client, addr)
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 File "/home/vcap/deps/0/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 135, in handle
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 Traceback (most recent call last):
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 During handling of the above exception, another exception occurred:
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 **ModuleNotFoundError: No module named 'matplotlib'**
13 de mar. de 2021 10:43:24
APP/PROC/WEB 0 import matplotlib.pyplot as plt在我运行ibmcloud dev build和ibmcloud dev运行的本地环境中,运行可以正常工作,但是在ibmcloud中部署之后,日志中会出现错误。
这是我的Dockerfile:
FROM registry.access.redhat.com/ubi8:8.3
WORKDIR /app
COPY Pipfile* /app/
## NOTE - rhel enforces user container permissions stronger ##
USER root
RUN yum -y install python3
RUN yum -y install python3-pip wget
RUN pip3 install --upgrade pip==21.0.1 \
&& pip3 install --upgrade pipenv==2020.11.15 \
&& pipenv install --system --deploy
RUN pip3 install numpy
RUN pip3 install wordcloud
RUN pip3 install requests
RUN pip3 install urllib3
RUN pip3 install matplotlib --force
RUN pip3 install six wikipedia-API --force
USER 1001
COPY . /app
ENV PORT 3000
EXPOSE 3000
CMD ["python3", "manage.py", "start"]这是我的manifest.yml
---
applications:
- instances: 1
timeout: 180
name: biblestatistic
buildpack: python_buildpack
command: gunicorn --env DJANGO_SETTINGS_MODULE=pythondjangoapp.settings.production pythondjangoapp.wsgi -b 0.0.0.0:$PORT
memory: 1024MB
domain: us-south.cf.appdomain.cloud
host: <my_host>发布于 2021-03-13 14:09:28
您的Dockerfile用于将应用程序作为容器运行。有了,你真的需要一个requirements.txt和你的应用程序所依赖的所有模块。您还需要一个runtime.txt来指定Python版本。看看这个有关Python和所需配置文件的云创建文档。
https://stackoverflow.com/questions/66614353
复制相似问题