Previously in our development environment we ran flask app from vscode but after we updated to the latest version of flask we started experiencing problems. After some investigation I found out that in our run configuration we specify the whole path to the app.py-file. Changing to just referencing it directly (i.e. app.py instead of C:\Path\To\Myapp.py) I got it to work.
I recreated the fault in another simpler environment:
The following command runs
env "FLASK_APP=`pwd`/app.py" "FLASK_ENV=Development" "FLASK_DEBUG=1" env/Scripts/python.exe -m flask run
but when you try to access localhost:5000/ you get the following error
```Traceback (most recent call last):
File "C:Users\AlexanderS\code\flask-bugg\env\lib\site-packages\flask\cli.py", line 330, in __call__
rv = self._load_unlocked()
File "C:Users\AlexanderS\code\flask-bugg\env\lib\site-packages\flask\cli.py", line 317, in _load_unlocked
self._app = rv = self.loader()
File "C:Users\AlexanderS\code\flask-bugg\env\lib\site-packages\flask\cli.py", line 372, in load_app
app = locate_app(self, import_name, name)
File "C:Users\AlexanderS\code\flask-bugg\env\lib\site-packages\flask\cli.py", line 246, in locate_app
'Could not import "{name}".'.format(name=module_name)
flask.cli.NoAppException: Could not import "C".
### Actual Behavior
The application should run without errors.
### Environment
* Python version: 3.6.5
* Flask version: 1.0.2
* Werkzeug version: 0.14.1
Recreated the bug with the follow app.py
```python
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello world2'
It doesn't seem to be supported to import an app through a path with disk driver under Windows.
Flask supports importing app through a combination of module path that does not contain a colon and app variable name, such as 'module_path : my_app'. So if you set FLASK_APP to a path with a colon, the error you described above will be raised.
Maybe we should use a regex to split this to avoid splitting on :/ and :\?
Thanks for the responses. I believe that this is something that never worked but vscode/vscode-python changed how they handle the launch configurations. I believe that perhaps this issue is related
Unless you think that this should be handled I'm OK with closing the issue.
closed by #2963
Most helpful comment
It doesn't seem to be supported to import an app through a path with disk driver under Windows.
Flask supports importing app through a combination of module path that does not contain a colon and app variable name, such as 'module_path : my_app'. So if you set
FLASK_APPto a path with a colon, the error you described above will be raised.