gpt4 book ai didi

python - Heroku、Django、工头

转载 作者:行者123 更新时间:2023-11-28 16:33:21 24 4
gpt4 key购买 nike

我正在学习本教程:http://tutorial.djangogirls.org/en/domain/README.html

但是当我运行 foreman start web 时,正如 heroku 文档中提到的 https://devcenter.heroku.com/articles/getting-started-with-python#run-the-app-locally我收到此错误:

03:43:05 web.1  | started with pid 47516
03:43:05 web.1 | Traceback (most recent call last):
03:43:05 web.1 | File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
03:43:05 web.1 | "__main__", mod_spec)
03:43:05 web.1 | File "C:\Python34\lib\runpy.py", line 85, in _run_code
03:43:05 web.1 | exec(code, run_globals)
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\Scripts\gunicorn.exe\_
_main__.py", line 5, in <module>
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\lib\site-packages\guni
corn\app\wsgiapp.py", line 10, in <module>
03:43:05 web.1 | from gunicorn.app.base import Application
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\lib\site-packages\guni
corn\app\base.py", line 12, in <module>
03:43:05 web.1 | from gunicorn import util
03:43:05 web.1 | File "c:\Users\shenk\Documents\Programming\django_projects\djangogirls\myvenv\lib\site-packages\guni
corn\util.py", line 9, in <module>
03:43:05 web.1 | import fcntl
03:43:05 web.1 | ImportError: No module named 'fcntl'
03:43:05 web.1 | exited with code 1
03:43:05 system | sending SIGKILL to all processes

我应该使用工头吗?我读到 gunicorn 是我应该使用的,但我不确定如何使用它。我找不到任何关于如何使用 gunicorn 启动服务器而不是 heroku openpython manage.py runserver

的示例

我听说 gunicorn 不能在 Windows 上运行...这是真的吗?我找到了这个答案,但不确定如何实现它.. fcntl substitute on Windows

假设我无法实现 fcntl 替代品,Windows 的解决方案是什么?如果可能,我想使用 gunicorn/foreman,因为 runserver 仅用于开发。我一直在使用 heroku,但我不确定这是否是正确的方法。从 Windows 部署/启动服务器的正确方法是什么?还是 Linux 是唯一的选择?

最佳答案

Gunicorn 不能在 Windows 上运行,因此您需要有一个单独的系统来在本地运行代码。你运行的是什么框架?

通常您可以使用内置的开发服务器(如 Django 的 python manage.py runserver)在本地进行开发,而只需在 Heroku 本身上使用 gunicorn

关于python - Heroku、Django、工头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29562199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com