命令提示符:pip install mod_wsgi

Command Prompt: pip install mod_wsgi

我正在 Windows 10 尝试在 virtualenv 上安装 mod_wsgi。我已经下载了 flask、python、VS、...一切。有什么解决方法吗?无法附上整个错误,因为它太长了。

(venv) C:\Users\cim\Desktop\api>pip install mod_wsgi
Collecting mod_wsgi
  Using cached mod_wsgi-4.7.1.tar.gz (498 kB)
Building wheels for collected packages: mod-wsgi
  Building wheel for mod-wsgi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\cim\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\cim\AppData\Local\Temp\3\pip-install-i1jx4yl7\mod-wsgi\setup.py'"'"'; __file__='"'"'C:\Users\cim\AppData\Local\Temp\3\pip-install-i1jx4yl7\mod-wsgi\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\cim\AppData\Local\Temp\pip-wheel-vuv34mr5'
       cwd: C:\Users\cim\AppData\Local\Temp\pip-install-i1jx4yl7\mod-wsgi\
  Complete output (211 lines):
  c:\users\cim\appdata\local\programs\python\python38-32\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'bugtrack_url'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.8
  creating build\lib.win32-3.8\mod_wsgi
  copying src\__init__.py -> build\lib.win32-3.8\mod_wsgi
  creating build\lib.win32-3.8\mod_wsgi\server
  copying src\server\apxs_config.py -> build\lib.win32-3.8\mod_wsgi\server
  copying src\server\environ.py -> build\lib.win32-3.8\mod_wsgi\server
  copying src\server\__init__.py -> build\lib.win32-3.8\mod_wsgi\server
  creating build\lib.win32-3.8\mod_wsgi\server\management
  copying src\server\management\__init__.py -> build\lib.win32-3.8\mod_wsgi\server\management
  creating build\lib.win32-3.8\mod_wsgi\server\management\commands
  copying src\server\management\commands\runmodwsgi.py -> build\lib.win32-3.8\mod_wsgi\server\management\commands
  copying src\server\management\commands\__init__.py -> build\lib.win32-3.8\mod_wsgi\server\management\commands
  creating build\lib.win32-3.8\mod_wsgi\docs
  copying docs\_build\html\__init__.py -> build\lib.win32-3.8\mod_wsgi\docs
  creating build\lib.win32-3.8\mod_wsgi\images
  copying images\__init__.py -> build\lib.win32-3.8\mod_wsgi\images
  copying images\snake-whiskey.jpg -> build\lib.win32-3.8\mod_wsgi\images
  running build_ext
  building 'mod_wsgi.server.mod_wsgi' extension
  creating build\temp.win32-3.8
  creating build\temp.win32-3.8\Release
  creating build\temp.win32-3.8\Release\src
  creating build\temp.win32-3.8\Release\src\server
  C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.26.28801\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\Apache24/include -Ic:\users\cim\appdata\local\programs\python\python38-32\include -Ic:\users\cim\appdata\local\programs\python\python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.26.28801\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.26.28801\include" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /Tcsrc/server\mod_wsgi.c /Fobuild\temp.win32-3.8\Release\src/server\mod_wsgi.obj
  mod_wsgi.c

我已经安装了 mod_wsgi 到我的 mac,我可以向你解释我的步骤,也许你可以得到提示。

  • 我从 official 站点下载了最新的软件包,而不是 pip

    原因是我在使用 pip

    时也遇到了错误
  • 我使用 tar xvfz mod_wsgi-4.6.tar.gaz 提取了文件。我不知道 windows 等效项

  • ./configure -> make -> make install

  • 最后一步:将 LoadModule wsgi_module modules/mod_wsgi.so 添加到 /usr/local/etc/httpd/httpd.conf

我重新启动了我的 Apache 服务器 apachectl restart

在 运行 之前,我确保 mod_wsgi 路径是正确的。对于我的 mac:/usr/local/lib/httpd/modules/mod_wsgi.so

找出问题所在。不小心下载了 32 位 python 包而不是 64 位。由于 Apache 和 VS 都是 64 位的,所以我遇到了这个错误。