Reputation: 61
I have python3.5.2 as my default python and i installed flask. Then i wrote a basic flaskapp.py to try and i have encountered this error:
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.
Here is my flaskapp.py:
from flask import Flask
from flask import request,render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('pages/pages/home/home.html')
if __name__ == '__main__' :
app.run()
Traceback:
Traceback (most recent call last):
File "<input>", line 6, in <module> File "C:\....\flask\app.py", line 345,
in init root_path=root_path)
File "C:\...\flask\helpers.py", line 843,
in init root_path = get_root_path(self.import_name)
File "C:\...\flask\helpers.py", line 721,
in get_root_path 'provided.' % import_name) RuntimeError:
Upvotes: 6
Views: 4301
Reputation: 355
You dont run this in your IDE. You run it in the command line. Go to the folder where your flaskapp.py file is and run py flaskapp.py
. Read more here: https://github.com/bev-a-tron/MyFlaskTutorial/blob/master/1_start.rst
Upvotes: 3
Reputation: 1340
This sentence
'No root path can be found for the provided module "builtins"'
is they trouble maker.. I assume you are running this in some IDE line by line, because I encoutered the same problem using IntelliJ and the python console.
Please check the value of the argument __name__
in this case. This will probably have the value "builtins".
However, when you actually run the full script, then the __name__
argument will be set to __main__
.
Upvotes: 3