这个是报错 运行的时候出现的
/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 statTraceback (most recent call last): File "/home/python/Desktop/flask_demo_01/app.py", line 79, inapp.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'
原因及解决办法:
这是Werkzeug 0.15中的一种新行为。降级到Werkzeug 0.14.1。
卸载
(flask_dome) python@ubuntu:~/Desktop/house_bjweb$ pip install WerkzeugRequirement 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.1Collecting 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.0Successfully 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