在windows上使用channels\u redis

2024-06-16 08:58:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试着跟随this basic django channels tutorial,我已经有了一个很好的开始。我能够成功地连接到我的websocket,当我的消费者收到消息时,它会正确地回显到前端。在

本教程的下一部分重点介绍使用channels_redis,以便允许多个通道都接收相同的消息,以便不同的客户端实例可以通过websockets彼此通信。在

在教程里他们说要跑

pip3 install channels_redis

如果失败,他们不会详细说明或提供任何故障排除。在

当我在我的windows机器(Python 3.7 32位)上运行此命令时,我得到以下stacktrace:

Installing collected packages: hiredis, aioredis, channels-redis
  Running setup.py install for hiredis ... error
    Complete output from command C:\work_repos\WebWorkspace\PersonQueue\venv\Scr
ipts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\o_O\\App
Data\\Local\\Temp\\pip-build-vk3mqeh1\\hiredis\\setup.py';f=getattr(tokenize, 'o
pen', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile
(code, __file__, 'exec'))" install --record C:\Users\o_O\AppData\Local\Temp\pip-
dyn4y_6y-record\install-record.txt --single-version-externally-managed --compile
 --install-headers C:\work_repos\WebWorkspace\PersonQueue\venv\include\site\pyth
on3.7\hiredis:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\hiredis
    copying hiredis\version.py -> build\lib.win32-3.7\hiredis
    copying hiredis\__init__.py -> build\lib.win32-3.7\hiredis
    running build_clib
    building 'hiredis_for_hiredis_py' library
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\vendor
    creating build\temp.win32-3.7\vendor\hiredis
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC
\14.15.26726\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Pr
ogram Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26
726\include" /Tcvendor/hiredis/read.c /Fobuild\temp.win32-3.7\vendor/hiredis/rea
d.obj
    read.c
    vendor/hiredis/read.c(34): fatal error C1083: Cannot open include file: 'str
ing.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Buil
dTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x86\\cl.exe' failed with exi
t status 2

这似乎是一个依赖关系hiredis的问题。在网上搜索时,我发现其他人在windows上使用hiredis时遇到了困难,但没有找到解决办法。在

所以我的问题是:在windows上可以使用channels_redis包吗?我知道windows显然不是最好的生产部署环境,但我并不打算部署在windows服务器上。在这一点上,我只是试图遵循一个基本教程,并建立一个简单的概念证明应用程序,它能够进行websocket通信。我没有选择在我的开发机器上使用Linux,所以我特别寻找一个基于windows的解决方案。在

编辑附加信息:

  • Windows 7系统
  • Python 3.7
  • Django 2.1款
  • 通道2.1.3
  • 我已经安装了微软的工具

Tags: installpybuildcreatingredisreadwindowslib