Heroku在Windows上似乎并不真正支持Python和Django

时间:2018-10-19 15:00:59

标签: python django windows heroku

在Python / Django应用程序上,Heroku似乎对Gunicorn有依赖性。 Windows不支持Gunicorn。有没有人成功或知道解决方法?

我的应用运行正常,但在Heroku或Heroku本地环境下运行不正常

错误:

...site-packages\gunicorn\util.py", line 9, in <module>
import fcntl
ModuleNotFoundError: No module named 'fcntl'
Exited with exit code null

1 个答案:

答案 0 :(得分:0)

为此怪罪Heroku似乎是不公平的。 Gunicorn 不支持Windows。 Heroku与Windows无关。

还有其他可能工作的WSGI Web服务器。例如,uWSGI has documentation for running on Heroku

快速摘要:

  • 确保uwsgiwerkzeug在您的requirements.txtPipfile / Pipfile.lock中,并且Git跟踪了这些文件

  • 创建并跟踪包含以下内容的uwsgi.ini文件

    [uwsgi]
    http-socket = :$(PORT)
    master = true
    processes = 4
    die-on-term = true
    module = werkzeug.testapp:test_app
    memory-report = true
    

    确保为您的应用正确设置module

  • 将您的Procfile更新为包含

    web: uwsgi uwsgi.ini
    

确保它可以与heroku local一起使用,然后推送到Heroku。