Python Forum

Full Version: Root path Flask IDE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I have a problem running an app built with Flask in PyCharm, but it is working correctly in the shell.
It seems to come from a root path, does anyone know how to fix it ?
Thanks,
Here is the code : the classical

#! /usr/bin/python
# -*- coding:utf-8 -*-
 
from flask import Flask
import os
app = Flask(__name__)
 
@app.route('/')
def index():
    return "Hello !"
 
if __name__ == '__main__':
    app.run(debug=True)
(Oct-30-2018, 09:29 AM)vandelouw Wrote: [ -> ]I have a problem running an app built with Flask in PyCharm
Exactly what problem do you have? Do you get any errors/traceback? What python version you use, what OS, etc.
Hi Buran,
yes sorry to have forgotten, here is the traceback of the error :

Error:
Traceback (most recent call last): File "<input>", line 6, in <module> File "/Users/romainvandelouw/anaconda/envs/pycharm/lib/python3.6/site-packages/flask/app.py", line 370, in __init__ root_path=root_path File "/Users/romainvandelouw/anaconda/envs/pycharm/lib/python3.6/site-packages/flask/helpers.py", line 884, in __init__ root_path = get_root_path(self.import_name) File "/Users/romainvandelouw/anaconda/envs/pycharm/lib/python3.6/site-packages/flask/helpers.py", line 756, in get_root_path 'provided.' % import_name) RuntimeError: No root path can be found for the provided module "builtins". This can happen because the module came from an import hook that does not provide file name information or because it's a namespace package. In this case the root path needs to be explicitly provided.
I'm running on a Mac, with Python3.6
Hi Larz60+,
thanks, I'll be more careful next time !