python 安装 mod_wsgi 时缺少 LibDir

LibDir missing in python install of mod_wsgi

尝试安装 mod_wsgi 这样我就可以得到一个我在 Windows 中制作的与 apache 连接的 django 程序(我猜现在在 linux 中这要容易得多,但是有一些windows-我只需要在我的 django 程序中做命令行垃圾,这迫使我使用 windows)。

这是我尝试通过 pip 安装时得到的结果:

C:\Users\me\Documents>pip install mod_wsgi
Collecting mod-wsgi
  Using cached mod_wsgi-4.4.13.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "c:\users\me\appdata\local\temp\pip-build-8o45w4\mod-wsgi\setup.py", line 304, in <module>
        'libpython%s.a' % PYTHON_VERSION)):
      File "c:\python27\lib\ntpath.py", line 65, in join
        result_drive, result_path = splitdrive(path)
      File "c:\python27\lib\ntpath.py", line 115, in splitdrive
        if len(p) > 1:
    TypeError: object of type 'NoneType' has no len()

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\me\appdata\local\temp\pip-build-8o45w4\mod-wsgi

我在这里问之前已经尝试了很多,包括 installing from the source - 在黑客攻击后有效,但给了我一个 "module PWD" not found 错误。我在一个完全不相关的线程上读到的内容与不使用 pip 安装它有关。

由于其他完全未知的原因,提供的二进制文件似乎不想 运行。我正在 运行ning Python 2.7 和 Apache 2.4,它们都是 Windows 2012 服务器上的 64 位。

一开始我在安装 APXS 时遇到了一些麻烦,它至少告诉我:

C:\>apxs -q libdir
C:\apache24\lib

但我不确定 python 所说的是不是同一个 libdir。

所以我破解了 c:\python27\lib\distutils\sysconfig.py 并添加了:

if name == "LIBDIR":
    return "c:\python27\lib"
else:
    return get_config_vars().get(name)

这似乎行得通,(有时行不通,但现在行得通了:

虽然有一些保留意见:

  C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python.0\VC\Bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:c:\python27\libs /LIBPATH:c:\python27\PCbuild /EXPORT:initmod_wsgi-py27 build\temp
.win32-2.7\Release\src/server\mod_wsgi.obj build\temp.win32-2.7\Release\src/server\wsgi_apache.obj build\temp.win32-2.7\Release\src/server\wsgi_buckets.obj build\temp.win32-2.7\Release\src/server\wsgi_convert.obj build\tem
p.win32-2.7\Release\src/server\wsgi_daemon.obj build\temp.win32-2.7\Release\src/server\wsgi_interp.obj build\temp.win32-2.7\Release\src/server\wsgi_logger.obj build\temp.win32-2.7\Release\src/server\wsgi_memory.obj build\t
emp.win32-2.7\Release\src/server\wsgi_metrics.obj build\temp.win32-2.7\Release\src/server\wsgi_restrict.obj build\temp.win32-2.7\Release\src/server\wsgi_server.obj build\temp.win32-2.7\Release\src/server\wsgi_stream.obj bu
ild\temp.win32-2.7\Release\src/server\wsgi_validate.obj /OUT:build\lib.win32-2.7\mod_wsgi\server\mod_wsgi-py27.pyd /IMPLIB:build\temp.win32-2.7\Release\src/server\mod_wsgi-py27.lib /MANIFESTFILE:build\temp.win32-2.7\Releas
e\src/server\mod_wsgi-py27.pyd.manifest -Lc:\python27\lib -Lc:\python27\Lib/config -lpython27
  LINK : warning LNK4044: unrecognized option '/Lc:\python27\lib'; ignored
  LINK : warning LNK4044: unrecognized option '/Lc:\python27\Lib/config'; ignored
  LINK : warning LNK4044: unrecognized option '/lpython27'; ignored
  LINK : error LNK2001: unresolved external symbol initmod_wsgi-py27
  build\temp.win32-2.7\Release\src/server\mod_wsgi-py27.lib : fatal error LNK1120: 1 unresolved externals
  error: command 'C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\link.exe' failed with exit status 1120

  ----------------------------------------
  Failed building wheel for mod-wsgi
Failed to build mod-wsgi
Installing collected packages: mod-wsgi
  Running setup.py install for mod-wsgi
Successfully installed mod-wsgi-4.4.13

当我尝试 运行 mod_wsgi-express.exe 我得到:

C:\Python27\Scripts>mod_wsgi-express.exe
Traceback (most recent call last):
  File "C:\Python27\Scripts\mod_wsgi-express-script.py", line 9, in <module>
    load_entry_point('mod-wsgi==4.4.13', 'console_scripts', 'mod_wsgi-express')()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2682, in load_entry_point
    return ep.load()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2355, in load
    return self.resolve()
  File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\python27\lib\site-packages\mod_wsgi\server\__init__.py", line 13, in <module>
    import pwd
ImportError: No module named pwd

这就是我现在所处的位置,我认为通过 pip 安装可以解决这个问题。

所以,我认为 libdir 部分仍然有问题,否则它应该会自动工作。

Windows 目前不支持可安装的 pip mod_wsgi。请参阅: