V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · 4026 views
    This topic created in 4031 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
        1
    sumw3  
    OP
       Apr 14, 2015
    如果把```app = Flask(__name__)```直接写到```views.py```中的没有问题,
    直接执行```gunicorn app.views:app```就可以了。
    kongxianghe
        2
    kongxianghe  
       Apr 14, 2015
    gunicorn 仅仅是个容器,为了应对不同配置要用到create_app
    http://flask.pocoo.org/docs/0.10/patterns/appfactories/
    elvis_w
        3
    elvis_w  
       Apr 14, 2015
    gunicorn app:app命令在哪个目录运行?
    elvis_w
        4
    elvis_w  
       Apr 14, 2015
    mportError: No module named fcntl 应该是Windows下的故障,这货只支持Unix/Linux
    yangzh
        5
    yangzh  
       Apr 14, 2015
    gunicorn 不支持 windows。

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