我正在使用自定义脚本运行Flask应用程序。还是尝试,无论如何。我在Windows 10上,应使用以下命令在Linux Docker容器中运行应用程序:docker-compose up apiDocker-compose是version 1.23.2。在dockerfile中,该api服务通过以下命令运行:command: python manage.py run --host "0.0.0.0" --with-threads在尝试启动时,我看到了异常OSError: [Errno 8] Exec format error: '/api/manage.py'我最初以为这将是“可怕的Windows行尾”,再次给我,但是dos2unix在我的所有源文件上运行都无法解决问题。如何避免此错误?manage.py import click from flask.cli import FlaskGroup from my_app_api import create_app def create_my_app(info): return create_app() @click.group(cls=FlaskGroup, create_app=create_my_app) def cli(): pass if __name__ == "__main__": cli()完整回溯api_1 | Traceback (most recent call last):api_1 | File "manage.py", line 22, in <module>api_1 | cli()api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 764, in __call__api_1 | return self.main(*args, **kwargs)api_1 | File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 380, in mainapi_1 | return AppGroup.main(self, *args, **kwargs)api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in mainapi_1 | rv = self.invoke(ctx)api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invokeapi_1 | return _process_result(sub_ctx.command.invoke(sub_ctx))api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 956, in invokeapi_1 | return ctx.invoke(self.callback, **ctx.params)api_1 | File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invokeapi_1 | return callback(*args, **kwargs)api_1 | File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_funcapi_1 | return ctx.invoke(f, obj, *args, **kwargs)
3 回答
慕标5832272
TA贡献1966条经验 获得超4个赞
这是Werkzeug 0.15中的新行为。降级到Werkzeug 0.14.1可能有效,但是不再支持0.14,因此最好按照其他答案中所述解决文件问题。
添加回答
举报
0/150
提交
取消