mod_wsgi

时间:2015-07-31 15:01:27

标签: django apache python-2.7 mod-wsgi

尝试安装mod_wsgi,这样我就可以得到一个django程序,我在Windows中用apache连接起来(现在猜测这在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\1\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\1\pip-build-8o45w4\mod-wsgi

我在问这里之前已经尝试了很多,包括installing from the source - 在黑客攻击后工作,但是给了我一个&#34;模块PWD&#34;找不到错误。在我读到的一个完全不相关的线程上,与没有用pip安装它有关。

由于其他完全未知的原因,提供的二进制文件似乎并不想运行。我在Windows 2012服务器上运行Python 2.7和Apache 2.4,都是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\9.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部分相混淆,否则它应该自动运行。

1 个答案:

答案 0 :(得分:1)

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