A-A+

Flask(__name__) ‘NoneType’ object is not iterable

2022年11月30日 11:26 学习笔记 暂无评论 共1227字 (阅读71 views次)

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

今天正常运行flask程序,但是系统报错,具体如下:

Traceback (most recent call last):
  File "s:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "s:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "s:/Python/python-jiaoben/seo/main.py", line 33, in 
    app = Flask(__name__)
  File "s:\Python\Python39\lib\site-packages\flask\app.py", line 409, in __init__
    instance_path = self.auto_find_instance_path()
  File "s:\Python\Python39\lib\site-packages\flask\app.py", line 641, in auto_find_instance_path
    prefix, package_path = find_package(self.import_name)
  File "s:\Python\Python39\lib\site-packages\flask\scaffold.py", line 839, in find_package
    package_path = _find_package_path(root_mod_name)
  File "s:\Python\Python39\lib\site-packages\flask\scaffold.py", line 790, in _find_package_path
    return os.path.dirname(next(iter(spec.submodule_search_locations)))
TypeError: 'NoneType' object is not iterable

一脸懵逼,后来经过查找发现,是pycharm的问题,升级就可以搞定,但是升级又太麻烦,所以,采取下面的办法。

app = Flask(__name__, instance_path="/{project_folder_abs_path}/instance")

在入口中加入instance_path="/{project_folder_abs_path}/instance"参数即可。

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×

给我留言