我有 python3.5.2 作为我的默认 python 并且我安装了flask。然后我写了一个基本的flaskapp.py来尝试,我遇到了这个错误:
运行时错误:找不到提供的模块“内置”的根路径。发生这种情况的原因是该模块来自不提供文件名信息的导入挂钩,或者因为它是命名空间包。在这种情况下,需要显式提供根路径。
这是我的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()
Run Code Online (Sandbox Code Playgroud)
追溯:
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:
Run Code Online (Sandbox Code Playgroud)
这个句子
'找不到提供的模块“内置”的根路径'
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__.
| 归档时间: |
|
| 查看次数: |
3805 次 |
| 最近记录: |