Flask错误:AttributeError:'NoneType'对象没有属性'startswith' [英] Flask error: AttributeError: 'NoneType' object has no attribute 'startswith'

查看:2928
本文介绍了Flask错误:AttributeError:'NoneType'对象没有属性'startswith'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图用引导程序这个烧瓶项目并启动并运行。

 文件run。 py,第5行,在< module> 
app = create_app()
文件/home/xx/flask-bootstrap/app/__init__.py,第21行,在create_app
config = os.path.join(app。 root_path,os.environ.get('FLASK_APPLICATION_SETTINGS'))
文件/home/xx/flask-bootstrap/venv/lib/python2.7/posixpath.py,第75行,加入
如果b.startswith('/'):
AttributeError:'NoneType'对象没有属性'startswith'

我已经使用 pip install -r config / requirements.txt 安装了给定的依赖项,但是它提供了一个错误信息。



在Ubuntu 14.04上,Gnome 3 DE。



pip freeze 在环境中为我提供了

 `Flask == 0.10.1 
Flask-Assets == 0.10
Flask-Bcrypt == 0.6.2
Flask-Login == 0.2。 11
Flask-Script == 2.0.5
Flask-SQLAlchemy == 2.0
Flask-WTF == 0.12
itsdangerous == 0.24
Jinja2 == 2.7。 3
jsmin == 2.1.2
MarkupSafe == 0.23
psycopg2 == 2.6.1
python-bcrypt == 0.3.1
SQLAlchemy == 1.0。 6
webassets == 0.10.1
Werkzeug == 0.10.4
wheel == 0.24.0
WTForms == 2.0.2`
FLASK_APPLICATION_SETTINGS , $ c>环境变量。



请参阅自述文件中的配置步骤

lockquote
$ ul

  • 如果你使用的是Makefile,设置您的配置文件名

  • 否则,您可以:


    • 使用 python manage.py -c config / yourconfig.cfg runserver 或其他
    • 传递您的配置文件
    • 设置一个环境变量 FLASK_APPLICATION_SETTINGS 指向您的配置文件
    • 检查以确保你的 SECRET_KEY 配置设置确实是秘密的并且密码学上强大(熵的120+位)
    • Makefile命令 make create_cfg 自动设置这个 SECRET_KEY 作为配置创建的一部分


    Attempting to fork this flask project with bootstrap and getting it up and running. I've followed the guide to the end on how to set it up, but I receive this error:

    File "run.py", line 5, in <module>
        app = create_app()
      File "/home/xx/flask-bootstrap/app/__init__.py", line 21, in create_app
        config = os.path.join(app.root_path, os.environ.get('FLASK_APPLICATION_SETTINGS'))
      File "/home/xx/flask-bootstrap/venv/lib/python2.7/posixpath.py", line 75, in join
        if b.startswith('/'):
    AttributeError: 'NoneType' object has no attribute 'startswith'
    

    I've installed the given dependencies with pip install -r config/requirements.txt yet it gives an error.

    On Ubuntu 14.04, Gnome 3 DE.

    pip freezein the environment provides me with

    `Flask==0.10.1
    Flask-Assets==0.10
    Flask-Bcrypt==0.6.2
    Flask-Login==0.2.11
    Flask-Script==2.0.5
    Flask-SQLAlchemy==2.0
    Flask-WTF==0.12
    itsdangerous==0.24
    Jinja2==2.7.3
    jsmin==2.1.2
    MarkupSafe==0.23
    psycopg2==2.6.1
    python-bcrypt==0.3.1
    SQLAlchemy==1.0.6
    webassets==0.10.1
    Werkzeug==0.10.4
    wheel==0.24.0
    WTForms==2.0.2`
    

    解决方案

    You get the error because there is no FLASK_APPLICATION_SETTINGS environment variable.

    See the configuration step in the readme:

    • If you're using the Makefile, be sure to set your config filename
    • Otherwise, you can either:
      • pass your config file using python manage.py -c config/yourconfig.cfg runserver or else
      • set an environmental variable FLASK_APPLICATION_SETTINGS to point to your config file
    • Check to be sure your SECRET_KEY config setting is indeed secret and cryptographically strong (120+ bits of entropy)
    • The Makefile command make create_cfg sets this SECRET_KEY automatically as part of the config creation

    这篇关于Flask错误:AttributeError:'NoneType'对象没有属性'startswith'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆