Flask CLI拋出'OSError:[Errno 8] Exec格式錯誤'

這個是報錯 運行的時候出現的python

/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'

緣由及解決辦法:git

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

[GitHub]:pallets / werkzeug - 0.15.0致使OSError:[Errno 8] Exec格式錯誤:在Docker for Windowsweb

這是Werkzeug 0.15中的一種新行爲。降級到Werkzeug 0.14.1。docker

卸載 flask

(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)

安裝ubuntu

(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

 

運行成功:session

/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
相關文章
相關標籤/搜索