推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
sumw3
V2EX  ›  Python

怎么通过 gunicorn 来执行定义在 app/__init.py__中的 app 啊?

  •  
  •   sumw3 · Apr 14, 2015 · 4465 views
    This topic created in 4226 days ago, the information mentioned may be changed or developed.

    app/__init.py中的代码如下:

    from flask import Flask
    
    app = Flask(__name__)
    app.config.from_object('config')
    
    from app import views
    

    想要通过gunicorn在运行app,
    不管是gunicorn app.__init__:app还是gunicorn app:app都提示ImportError: No module named fcntl。

    Python新手,求教。

    7 replies  •  2015-04-14 16:52:03 +08:00
    sumw3
    sumw3
    OP
    Apr 14, 2015
    1
    如果把```app = Flask(__name__)```直接写到```views.py```中的没有问题,
    直接执行```gunicorn app.views:app```就可以了。
    kongxianghe
    kongxianghe
    Apr 14, 2015
    2
    gunicorn 仅仅是个容器,为了应对不同配置要用到create_app
    http://flask.pocoo.org/docs/0.10/patterns/appfactories/
    elvis_w
    elvis_w
    Apr 14, 2015
    3
    gunicorn app:app命令在哪个目录运行?
    elvis_w
    elvis_w
    Apr 14, 2015
    4
    mportError: No module named fcntl 应该是Windows下的故障,这货只支持Unix/Linux
    yangzh
    yangzh
    Apr 14, 2015
    5
    gunicorn 不支持 windows。

    换 linux 试试 gunicorn app:app 吧。
    sumw3
    sumw3
    OP
    Apr 14, 2015
    6
    @elvis_w 是的,查了一圈才知道,晚点用MAC试试。
    elvis_w
    elvis_w
    Apr 14, 2015
    7
    @sumw3 windows可以用twisted运行flask,记得装pywin32
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   748 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:33 · PVG 01:33 · LAX 09:33 · JFK 12:33
    ♥ Do have faith in what you're doing.