[英]Python flask reloader “Errno 2 No such file or directory” error when running on docker
I have a problem running a little Flask app with Docker. 我在使用Docker运行一个Flask应用程序时遇到问题。 Everything works fine with debug off, but when I try to run it with debug on it fails at the reloader stage.
调试关闭时一切正常,但是当我尝试使用debug运行它时,它在重载器阶段失败了。 It works fine on Windows, the problem only comes up with Docker.
它在Windows上工作正常,问题只出现在Docker上。
In my docker repo I install caffe and all the dependencies I need (flask and wekrzeug). 在我的docker repo中,我安装了caffe和我需要的所有依赖项(flask和wekrzeug)。 I thought the problem could be with the reloader so I also installed watchdog but it still shows up.
我认为问题可能出在重新加载器上,所以我也安装了看门狗,但它仍然显示出来。 Doesn't matter whether I run app.py itself or call python -m flask run.
无论我是运行app.py本身还是调用python -m flask run。
docker run --volume=%cd%:/workspace -p 5001:5000 caffe:cpu
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with inotify reloader
Traceback (most recent call last):
File "app.py", line 53, in <module>
app.run(debug = True, host='0.0.0.0')
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 943, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 988, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ, close_fds=False)
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I've encountered the same problem here and the solution for me was to remove the executable flag from the "run.py" file. 我在这里遇到了同样的问题,我的解决方案是从“run.py”文件中删除可执行标志。
$ chmod -x run.py
$ chmod -x run.py
The error was very similar, but in my case I'm using an Ubuntu 18.04 WSL on a Windows 10 machine. 错误非常相似,但在我的情况下,我在Windows 10机器上使用Ubuntu 18.04 WSL。
Try to run the app as a module: 尝试将应用程序作为模块运行:
python -m flask run
See https://github.com/pallets/flask/issues/1829 for more information. 有关更多信息,请参阅https://github.com/pallets/flask/issues/1829 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.