Flask CLI抛出'OSError:[Errno 8] Exec格式错误'

让人想犯罪 __ 提交于 2020-01-28 05:47:56

这个是报错 运行的时候出现的

/home/python/.virtualenvs/flask_dome/bin/python3.6 /home/python/Desktop/flask_demo_01/app.py
 * 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://192.168.0.140:8888/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File "/home/python/Desktop/flask_demo_01/app.py", line 79, in <module>
    app.run(host='192.168.0.140',port=8888)
  File "/home/python/.virtualenvs/flask_dome/lib/python3.6/site-packages/flask/app.py", line 943, in run
    run_simple(host, port, self, **options)
  File "/home/python/.virtualenvs/flask_dome/lib/python3.6/site-packages/werkzeug/serving.py", line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
  File "/home/python/.virtualenvs/flask_dome/lib/python3.6/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
  File "/home/python/.virtualenvs/flask_dome/lib/python3.6/site-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
  File "/usr/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/python/Desktop/flask_demo_01/app.py'

原因及解决办法:

https://stackoverflow.com/questions/55271912/flask-cli-throws-oserror-errno-8-exec-format-error-when-run-through-docker

[GitHub]:pallets / werkzeug - 0.15.0导致OSError:[Errno 8] Exec格式错误:在Docker for Windows

这是Werkzeug 0.15中的一种新行为。降级到Werkzeug 0.14.1。

卸载 

(flask_dome) python@ubuntu:~/Desktop/house_bjweb$ pip install Werkzeug
Requirement already satisfied: Werkzeug in /home/python/.virtualenvs/flask_dome/lib/python3.6/site-packages (0.15.0)

安装

(flask_dome) python@ubuntu:~/Desktop/house_bjweb$ pip install Werkzeug==0.14.1
Collecting Werkzeug==0.14.1
  Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
     |████████████████████████████████| 327kB 12kB/s 
Installing collected packages: Werkzeug
  Found existing installation: Werkzeug 0.15.0
    Uninstalling Werkzeug-0.15.0:
      Successfully uninstalled Werkzeug-0.15.0
Successfully installed Werkzeug-0.14.1

 

运行成功:

/home/python/.virtualenvs/flask_dome/bin/python3.6 /home/python/Desktop/flask_demo_01/app.py
 * 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://192.168.0.140:8888/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 264-574-474

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!