赞
踩
源码参见:Yolov5-Flask-VUE:在WEB端部署YOLOv5目标检测模型-源码
参见 : 安装 — Flask 0.10.1 文档
1、sudo apt-get install python3-pip
2、sudo pip3 install Flask
- (yolov5) robot@robot-All-Series:~$ sudo pip3 install Flask
- Collecting Flask
- Downloading Flask-2.0.3-py3-none-any.whl (95 kB)
- |████████████████████████████████| 95 kB 659 kB/s
- Collecting Jinja2>=3.0
- Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
- |████████████████████████████████| 133 kB 317 kB/s
- Collecting itsdangerous>=2.0
- Downloading itsdangerous-2.1.1-py3-none-any.whl (15 kB)
- Collecting click>=7.1.2
- Downloading click-8.0.4-py3-none-any.whl (97 kB)
- |████████████████████████████████| 97 kB 416 kB/s
- Collecting Werkzeug>=2.0
- Downloading Werkzeug-2.0.3-py3-none-any.whl (289 kB)
- |████████████████████████████████| 289 kB 222 kB/s
- Collecting MarkupSafe>=2.0
- Downloading MarkupSafe-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
- Installing collected packages: MarkupSafe, Jinja2, itsdangerous, click, Werkzeug, Flask
- Attempting uninstall: MarkupSafe
- Found existing installation: MarkupSafe 1.1.0
- Not uninstalling markupsafe at /usr/lib/python3/dist-packages, outside environment /usr
- Can't uninstall 'MarkupSafe'. No files were found to uninstall.
- Attempting uninstall: click
- Found existing installation: Click 7.0
- Not uninstalling click at /usr/lib/python3/dist-packages, outside environment /usr
- Can't uninstall 'Click'. No files were found to uninstall.
- Successfully installed Flask-2.0.3 Jinja2-3.0.3 MarkupSafe-2.1.0 Werkzeug-2.0.3 click-8.0.4 itsdangerous-2.1.1
二、入门
编写app.py
- from flask import Flask
- app = Flask(__name__)
-
- @app.route('/')
- def hello_world():
- return 'Hello World!'
-
- if __name__ == '__main__':
- app.run()
python3 app.py
提示错误,找不到库
- Traceback (most recent call last):
- File "/home/robot/flask-test/app.py", line 1, in <module>
- from flask import Flask
- ModuleNotFoundError: No module named 'flask
我用的anaconda虚拟环境。所以:
pip uninstall Flask && python3 -m pip install flask
然后重新执行
- (yolov5) robot@robot-All-Series:~/flask-test$ python3 app.py
- * Serving Flask app 'app' (lazy loading)
- * Environment: production
- WARNING: This is a development server. Do not use it in a production deployment.
- Use a production WSGI server instead.
- * Debug mode: off
- * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
- 127.0.0.1 - - [11/Mar/2022 11:29:23] "GET / HTTP/1.1" 200 -
- 127.0.0.1 - - [11/Mar/2022 11:29:23] "GET /favicon.ico HTTP/1.1" 404 -
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。