简体   繁体   English

在docker上运行时,Python烧瓶重新加载器“Errno 2没有这样的文件或目录”错误

[英]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.

相关问题 在docker容器上运行flask应用程序:错误:python:无法打开文件&#39;//run.py&#39;:[Errno 2]没有这样的文件或目录Docker错误 - having on running flask app on docker container : Error: python: can't open file '//run.py': [Errno 2] No such file or directory Docker Error 在本地 Apache 光束安装上运行 SqlTransform Python SDK。 收到错误:“FileNotFoundError:[Errno 2] 没有这样的文件或目录:'docker'” - Running SqlTransform Python SDK on local Apache Beam instalation. Error received: “FileNotFoundError: [Errno 2] No such file or directory: 'docker'” Docker容器无法运行,错误:python3:无法打开文件“ flask run --host = 0.0.0.0”:[Errno 2]没有此类文件或目录 - Docker container fails to run, Error : python3: can't open file 'flask run --host=0.0.0.0': [Errno 2] No such file or directory Docker 运行 Python 错误 - [错误 2] 没有这样的文件或目录 - Docker Running Python Error - [Error 2] No such file or directory 在终端中运行 python 脚本时出错:OSError: [Errno 2] No such file or directory - Error running python script in terminal: OSError: [Errno 2] No such file or directory Flask [Errno 2] 没有这样的文件或目录: - Flask [Errno 2] No such file or directory: 运行Docker容器时没有此类文件或目录错误 - No such file or directory error when running Docker container Python/Docker: FileNotFoundError: [Errno 2] 没有这样的文件或目录: - Python/Docker : FileNotFoundError: [Errno 2] No such file or directory: python - IO错误[Errno 2]下载包时没有这样的文件或目录 - python - IO Error [Errno 2] No such file or directory when downloading package 出现错误:FileNotFoundError: [Errno 2] No such file or directory when using Python open() - Getting error: FileNotFoundError: [Errno 2] No such file or directory when using Python open()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM