Flask ": the provided file / path does not exist, although the file exists

I use export FLASK_APP=flask_app and then flask run , but I get an error:

Error: File / path (flask_app) does not exist. Check the correct path. If the application is not included in PYTHONPATH, make sure the extension is .py

However, the file exists and even resides in the current working directory. Using the full path to the file also does not work.

+6
source share
4 answers

This situation occurs when you have an ImportError that does not apply to your terminal. Check all your files for invalid import statements, fix them and the error should go away.

EDIT 2017-04-02: Michael noted that my link placed under the "OLD MESSAGE PART 2" tag is incorrect. I don’t know how this error occurred, but I found the last post on Flask Github , where they refer to a commit , which was supposed to fix the problem on December 30, 2016. Probably at that time I was really launching an older version of the jar.

OLD MESSAGE PART 2: This question is discussed on the Flask Github , although I’m not sure when and even if it was really fixed, as I still encounter the error today, although I downloaded Flask after merging the fix described on this page (12 August 2016).

+19
source

I see this error when I miss the import statement somewhere in my code. The fact that the actual import error is not displayed, in my opinion, is an error, as described in @PDiracDelta answer . ( Update : it looks like it will be fixed in Flask 0.13.)

The workaround that works for me is to specify the application on the command line. From the error message you provided, it looks like your application is called "flask_app", so just type this:

 python flask_app.py 

This does not actually start the application (if it does not check if __name__ == '__main__' or something else), but it will show import errors.

+5
source

Please follow these steps: 1> Make sure you have already done this with [pip install -editable. ]. where '.' indicate the location of the directory in which your application is installed. for example (flask_app) 2> Run python It will open the python command line interpreter 3> Try to import the flash application If its an error, you will get a detailed error. Try to fix this error.

I ran into one problem and followed the following steps and found that there was an error in the running code. The interpreter shows a compilation error.

0
source

The werkzeug version is not suitable for a flask. To solve this problem you need to upgrade werkzeug, use: $pip install werkzeug --upgrade

0
source

Source: https://habr.com/ru/post/1014519/


All Articles