pip 不会安装 channels_redis

pip won't install channels_redis

为了使用 Django 频道,我需要安装“channels_redis”。 安装“channels_redis”时遇到此错误,有什么想法吗?

顺便说一下,我在 windows 上,它首先显示 C++ 错误,然后在安装 Microsoft visual studio 构建工具后消失,现在这个。

  ERROR: Command errored out with exit status 1:
   command: 'E:\Programming projects\Django\channels\chat_launch01\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0]
 = '"'"'C:\Users\KaNi\AppData\Local\Temp\pip-install-dt2d0_z3\hiredis_a7d15f1044b343288a4bc87864c6418e\setup.py'"'"'; __file__='"'"'C:\
Users\KaNi\AppData\Local\Temp\pip-install-dt2d0_z3\hiredis_a7d15f1044b343288a4bc87864c6418e\setup.py'"'"';f=getattr(tokenize, '"'"'open'"
'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d
 'C:\Users\KaNi\AppData\Local\Temp\pip-wheel-m0bnautd'
       cwd: C:\Users\KaNi\AppData\Local\Temp\pip-install-dt2d0_z3\hiredis_a7d15f1044b343288a4bc87864c6418e\
  Complete output (23 lines):
  C:\Users\KaNi\AppData\Local\Temp\pip-install-dt2d0_z3\hiredis_a7d15f1044b343288a4bc87864c6418e\setup.py:7: DeprecationWarning: the imp module
is deprecated in favour of importlib; see the module's documentation for alternative uses
    import sys, imp, os, glob, io
  E:\Programming projects\Django\channels\chat_launch01\venv\lib\site-packages\setuptools\dist.py:642: UserWarning: Usage of dash-separated 'des
cription-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
    warnings.warn(
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\hiredis
  copying hiredis\version.py -> build\lib.win-amd64-3.9\hiredis
  copying hiredis\__init__.py -> build\lib.win-amd64-3.9\hiredis
  running build_ext
  building 'hiredis.hiredis' extension
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  creating build\temp.win-amd64-3.9\Release\src
  creating build\temp.win-amd64-3.9\Release\vendor
  creating build\temp.win-amd64-3.9\Release\vendor\hiredis
  d:\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ivendor -IE:\
Programming projects\Django\channels\chat_launch01\venv\include -Ic:\users\kani\appdata\local\programs\python\python39\include -Ic:\users\kani\a
ppdata\local\programs\python\python39\include -Id:\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.28.29910\include -IC:\Program Files
(x86)\Windows Kits\include.0.10240.0\ucrt /Tcsrc\hiredis.c /Fobuild\temp.win-amd64-3.9\Release\src\hiredis.obj
  hiredis.c
  c:\users\kani\appdata\local\programs\python\python39\include\pyconfig.h(200): fatal error C1083: Cannot open include file: 'basetsd.h': No suc
h file or directory
  error: command 'd:\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe' failed with exit code
2
  ----------------------------------------
  ERROR: Failed building wheel for hiredis

发生这种情况是因为您的构建工具存在问题。因此,

  1. 如果您的构建工具进一步无法解决您的问题,请尝试通过此 link.

    手动安装构建工具
  2. 之后,您必须重新启动您的 PC 或笔记本电脑。

  3. 然后再次尝试运行您的代码

当您在 windows 系统中尝试在 venv Python 环境而不是主系统中安装 channels_redis 时出现问题,

尝试在任何虚拟环境之外安装并运行项目,即进入主系统。