1. Problem description
When flask initializes the database file, execute flask init-db to report Error: Could not locate a Flask application. Use the ‘flask –app’ option, ‘FLASK_APP’ environment variable, or a ‘wsgi.py’ or ‘app.py’ file in the current directory, the specific error screenshot is as follows:
2. Problem solving
This problem is really annoying. I can’t find the corresponding solution on Baidu. The official document about the flask initialization database is also very vague. I wrote an execution command directly, so I don’t understand it very well, so I do it when initializing the database. The operation is:
1. Shut down the previously started server, open a new terminal and execute the following command:
1
2
3
|
% export FLASK_APP=flaskr % export FLASK_ENV=development %flask run |
2. Open another terminal and cd to the package directory to execute the flask inti-db command, and the above error is reported. Obviously this is the wrong step.
3. Solutions
After thinking about this problem for a long time, I want to understand where I am wrong. The correct execution steps should be:
1. Execute the following command
1
2
3
|
% export FLASK_APP=flaskr % export FLASK_ENV=development %flask init-db |
2. After the execution is successful, a flaskr.sqlite file will be created in the instance folder. The actual result is shown as follows:
Read More:
- [Solved] Docker+uWSGI+Flask Error: ModuleNotFoundError: No module named ‘flask‘
- Flask Startup Error: s.bind(server_address)PermissionError: [Errno 13] Permission denied
- Docker Create tomcat Error standard_init_linux.go:211: exec user process caused “no such file or directory”
- [619]libgtk-3.so.0 or libXt.so.6: cannot open shared object file: No such file or directory
- [Solved] ERROR: Could not open requirements file: [Errno 2] No such file or directory : ‘requirments.txt‘
- Keil Compile Error: ..\OBJ\USART.axf: error: L6002U: Could not open file ..\obj\sys.o: No such file or directory
- [Solved] PostgreSQL Error: Could not connect to server: no such file or directory
- [Solved] import cv2 Error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- VSCode Unable to find custom header file directory: fatal error: no such file or directory
- SLAMBook2 in ch3 code run fatal error: Eigen/Core: No such file or directory
- [Solved] MYSQLD: Can‘t create directory ‘/usr/local/mysql/data/’(Errcode:2 -No such file or directory)
- [Solved] MSYS2+ fatal error: zlib.h: There is no such file or directory
- crtdbg.h No such file or directory error [How to Solve]
- error while loading shared libraries: lib*.so: cannot open shared object file: No such file or directory
- [Solved] fatal error C1083: Could Not Open Unable to open include file:“stdint.h”: No such file or directory
- [Solved] MindSpore Error: ReduceMean in the Ascend environment does not support inputs of 8 or more dimensions
- [Solved] MAC Nginx Error: ginx.pid“ failed (2: No such file or directory)
- Vue Report Error #NULL! :no such file or directory,chmod….. [email protected] **\css- Beautify.js
- Centos pip install uwsgi error: “fatal error: Python.h: No such file or directory”
- [Solved] import mxnet Error: OSError: libcudart.so.8.0: cannot open shared object file: No such file or directory