无法在Windows 10上构建mod_wsgi-“无法打开包含文件:'ws2tcpip.h'”-具有VS 2019生成工具

时间:2019-09-27 13:55:06

标签: python windows apache mod-wsgi

我安装了apache 2.4(64位),python 3.7(64位)(如果需要的话,是从Anaconda安装的)和VS 2019 C ++构建工具,并已检查SDK和构建此工具所需的所有其他功能。我仍然无法使用pip install构建mod_wsgi。如何在Windows 10上使用它?

我尝试卸载并重新安装python,Visual Studio和Visual Studio构建工具以及apache。我已经尝试了所有各种Visual Studio命令提示符。我检查了堆栈溢出,github和其他站点。还有其他人也有类似的问题,但是安装构建工具的解决方案对我不起作用,因为a。)我已经安装了它,b。)我重新安装了所有内容,但仍然不起作用。

pip install mod_wsgi

产生的错误消息:

Collecting mod_wsgi
  Using cached https://files.pythonhosted.org/packages/26/03/a3ed5abc2e66c82c40b0735c2f819c898d136879b00be4f5537126b6a4a4/mod_wsgi-4.6.7.tar.gz
Building wheels for collected packages: mod-wsgi
  Building wheel for mod-wsgi (setup.py) ... error
  ERROR: Complete output from command 'C:\Users\VC046230\AppData\Local\Continuum\anaconda3\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\VC046230\\AppData\\Local\\Temp\\pip-install-12r9v42f\\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\VC046230\AppData\Local\Temp\pip-wheel-1q_bver8' --python-tag cp37:
  ERROR: C:\Users\VC046230\AppData\Local\Continuum\anaconda3\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.win-amd64-3.7
  creating build\lib.win-amd64-3.7\mod_wsgi
  copying src\__init__.py -> build\lib.win-amd64-3.7\mod_wsgi
  creating build\lib.win-amd64-3.7\mod_wsgi\server
  copying src\server\apxs_config.py -> build\lib.win-amd64-3.7\mod_wsgi\server
  copying src\server\environ.py -> build\lib.win-amd64-3.7\mod_wsgi\server
  copying src\server\__init__.py -> build\lib.win-amd64-3.7\mod_wsgi\server
  creating build\lib.win-amd64-3.7\mod_wsgi\server\management
  copying src\server\management\__init__.py -> build\lib.win-amd64-3.7\mod_wsgi\server\management
  creating build\lib.win-amd64-3.7\mod_wsgi\server\management\commands
  copying src\server\management\commands\runmodwsgi.py -> build\lib.win-amd64-3.7\mod_wsgi\server\management\commands
  copying src\server\management\commands\__init__.py -> build\lib.win-amd64-3.7\mod_wsgi\server\management\commands
  creating build\lib.win-amd64-3.7\mod_wsgi\docs
  copying docs\_build\html\__init__.py -> build\lib.win-amd64-3.7\mod_wsgi\docs
  creating build\lib.win-amd64-3.7\mod_wsgi\images
  copying images\__init__.py -> build\lib.win-amd64-3.7\mod_wsgi\images
  copying images\snake-whiskey.jpg -> build\lib.win-amd64-3.7\mod_wsgi\images
  running build_ext
  building 'mod_wsgi.server.mod_wsgi' extension
  creating build\temp.win-amd64-3.7
  creating build\temp.win-amd64-3.7\Release
  creating build\temp.win-amd64-3.7\Release\src
  creating build\temp.win-amd64-3.7\Release\src\server
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\Apache24/include -IC:\Users\VC046230\AppData\Local\Continuum\anaconda3\include -IC:\Users\VC046230\AppData\Local\Continuum\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\include" /Tcsrc/server\mod_wsgi.c /Fobuild\temp.win-amd64-3.7\Release\src/server\mod_wsgi.obj
  mod_wsgi.c
  C:\Users\VC046230\AppData\Local\Temp\pip-install-12r9v42f\mod-wsgi\src\server\wsgi_apache.h(39): fatal error C1083: Cannot open include file: 'ws2tcpip.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for mod-wsgi

2 个答案:

答案 0 :(得分:1)

我刚刚解决了同样的问题。我的配置是Windows 10,Python 3.8.1,Apache2.4.39-Win64-VC15-OpenSSL1.1.1b,mod-wsgi 4.7.1。

1)我使用Build Tools

安装
  • Visual Studio生成工具主要组件
  • 因为我正在使用Windows 10,所以适用于Windows 10(10.0.18362.0)的SDK
  • MSVC 140-C ++ VS 2015(v.14.00)

2)然后我将C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ bin添加到PATH

3)然后出现下一个错误:

'apr_perms_set.h': No such file or directory'.

我下载了file并将其放入$ APACHE_DIR \ include

4)然后我得到了第三个错误:

fatal error LNK1158: cannot run ‘rc.exe’.
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158

我从C:\ Program Files(x86)\ Windows Kits \ 10 \ bin \ 10.0.18362.0 \ x86中提取了以下文件rc.exe rcdll.dll并将其粘贴到C:\ Program Files(x86)\ Microsoft Visual Studio中14.0 \ VC \ bin

5)恭喜!

答案 1 :(得分:1)

对于遇到此问题的任何人,以下 github 问题帮助我解决了它:https://github.com/GrahamDumpleton/mod_wsgi/issues/194

我已经安装了 Visual C++ Redistributable,所以我很困惑为什么 pip install mod_wsgi 仍然不起作用。

我最终要做的就是从 https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/

安装 Windows 10 SDK

(如果还是不行,可能还需要 8.1)