构建时Azure应用服务python模块导入错误

时间:2019-03-02 13:20:00

标签: python azure-webapps

直到昨天晚上,我已经成功地部署了Python Flask linux网络应用程序。在我的最新部署中,对我的应用程序的唯一更改是添加了一条新路由(没有新的python模块)。但是,该版本出现以下错误:

2019-03-02T04:46:08.721673278Z [2019-03-02 04:46:08 +0000] [34] [INFO] 
Starting gunicorn 19.9.0
2019-03-02T04:46:08.731049340Z [2019-03-02 04:46:08 +0000] [34] [INFO] Listening at: http://0.0.0.0:8000 (34)
2019-03-02T04:46:08.731060340Z [2019-03-02 04:46:08 +0000] [34] [INFO] Using worker: sync
2019-03-02T04:46:08.740437601Z [2019-03-02 04:46:08 +0000] [37] [INFO] Booting worker with pid: 37
2019-03-02T04:46:10.919571939Z [2019-03-02 04:46:10 +0000] [37] [ERROR] Exception in worker process
2019-03-02T04:46:10.919591939Z Traceback (most recent call last):
2019-03-02T04:46:10.919596839Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-03-02T04:46:10.919610339Z     worker.init_process()
2019-03-02T04:46:10.919615539Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-03-02T04:46:10.919619939Z     self.load_wsgi()
2019-03-02T04:46:10.919623739Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-03-02T04:46:10.919627939Z     self.wsgi = self.app.wsgi()
2019-03-02T04:46:10.919631639Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-03-02T04:46:10.919635639Z     self.callable = self.load()
2019-03-02T04:46:10.919639439Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-03-02T04:46:10.919651139Z     return self.load_wsgiapp()
2019-03-02T04:46:10.919655538Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-03-02T04:46:10.919659638Z     return util.import_app(self.app_uri)
2019-03-02T04:46:10.919663338Z   File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2019-03-02T04:46:10.919667338Z     __import__(module)
2019-03-02T04:46:10.919671038Z   File "/home/site/wwwroot/application.py", line 3, in <module>
2019-03-02T04:46:10.919675238Z     import utils
2019-03-02T04:46:10.919678938Z   File "/home/site/wwwroot/utils.py", line 2, in <module>
2019-03-02T04:46:10.919682938Z     import psycopg2
2019-03-02T04:46:10.919686738Z   File "/home/site/wwwroot/__oryx_packages__/psycopg2/__init__.py", line 50, in <module>
2019-03-02T04:46:10.919690638Z     from psycopg2._psycopg import (                     # noqa
2019-03-02T04:46:10.919694838Z ImportError: libpq-bd31fe2b.so.5.11: cannot open shared object file: No such file or directory
2019-03-02T04:46:10.920295036Z [2019-03-02 04:46:10 +0000] [37] [INFO] Worker exiting (pid: 37)
2019-03-02T04:46:11.013747652Z [2019-03-02 04:46:11 +0000] [34] [INFO] Shutting down: Master
2019-03-02T04:46:11.013775151Z [2019-03-02 04:46:11 +0000] [34] [INFO] Reason: Worker failed to boot.
2019-03-02 04:46:12.038 ERROR - Container rich-py-api_0 for site rich-py-api has exited, failing site start

我正在使用免费试用订阅。因为我无法控制python软件包的安装?

1 个答案:

答案 0 :(得分:0)

带有Python的Linux appservice仍在Preview中,Microsoft正在研究使部署不确定的竞争条件(请参见问题跟踪器和PR,请参见https://github.com/Microsoft/vscode-azureappservice/issues)。我遇到了这个相同的问题,再加上几个类似的问题。我的印象是,在创建新的Linux应用程序服务之后进行的首次部署比后续的部署更可靠。因此,我不得不拆除Appservice,使用Azure CLI从头开始重新创建它,然后从头开始重新部署所有服务。在创建和重新部署之间,我还通过SSH进入容器并为我正在使用的某些Python软件包安装缺少的构建依赖项。

apt-get update && apt-get install -y libssl-dev libffi-dev python-dev python-pip libpq5

也许现在使用定制的Docker容器是最安全的。