Python Forum
Root path Flask IDE - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Root path Flask IDE (/thread-13753.html)



Root path Flask IDE - vandelouw - Oct-30-2018

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)



RE: Root path Flask IDE - buran - Oct-30-2018

(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.


RE: Root path Flask IDE - vandelouw - Oct-30-2018

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


RE: Root path Flask IDE - vandelouw - Oct-30-2018

Hi Larz60+,
thanks, I'll be more careful next time !