简体   繁体   English

无法在Mac上的Django中安装mod_wsgi

[英]Cant install mod_wsgi in Django on Mac

I've been having trouble installing mod_wsgi on Django. 我在Django上安装mod_wsgi时遇到了麻烦。 This is the traceback for the terminal. 这是终端的回溯。 I'm using MacOS. 我正在使用MacOS。

Mac-mini-3:~ Sqooge_Ahmed$ pip install mod_wsgi
Collecting mod_wsgi
  Using cached mod_wsgi-4.5.7.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/14/x0m8m6p16bs9mfrmrs54zrjc0000gn/T/pip-build-0NyGFW/mod-wsgi/setup.py", line 247, in <module>
        APR_INCLUDES = get_apr_includes().split()
      File "/private/var/folders/14/x0m8m6p16bs9mfrmrs54zrjc0000gn/T/pip-build-0NyGFW/mod-wsgi/setup.py", line 219, in get_apr_includes
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
        errread, errwrite)
      File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1343, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/14/x0m8m6p16bs9mfrmrs54zrjc0000gn/T/pip-build-0NyGFW/mod-wsgi/

I've already updated the setuptools using 我已经使用了更新了setuptools

pip install --upgrade setup

If you are using MacOS X Sierra, then the problem is that Apple completely broke the ability to install third party Apache modules by no longer supplying certain command line tools required to do that. 如果您使用的是MacOS X Sierra,则问题在于Apple不再提供安装命令行工具所需的某些命令行工具,从而完全破坏了安装第三方Apache模块的能力。

Even so, in mod_wsgi 4.5.8 there is a workaround that allows pip install mod_wsgi to still work. 即使如此,在mod_wsgi 4.5.8中,仍存在一种变通方法,可以使pip install mod_wsgi仍然有效。 This only works for the pip method of installation though and not the older style configure/make/make install method, which can't find an easy workaround for. 这仅适用于pip安装方法,而不适用于较旧的configure / make / make install方法,后者找不到简单的解决方法。

Right at this instant in time 4.5.8 isn't released though but will be in the next day or so. 尽管此时4.5.8尚未发布,但将在第二天左右发布。 In the interim you can install from the GitHub repository by running: 在过渡期间,您可以通过运行以下命令从GitHub存储库安装:

pip install https://github.com/GrahamDumpleton/mod_wsgi/archive/develop.zip

As to the idea that there is no reason to install mod_wsgi for development, that is misleading. 至于没有理由安装mod_wsgi进行开发的想法,这是一种误导。 One of the main points of mod_wsgi-express is to make it very easy to use for development, including with Django. mod_wsgi-express的主要要点之一是使其非常易于开发,包括Django。 It is better to use mod_wsgi-express than the built in development server in some respects because you are then using a WSGI server which works in the same way as production would. 在某些方面,最好使用mod_wsgi-express不是内置的开发服务器,因为然后使用的是与生产方式相同的WSGI服务器。 This means you will pick up problems that relate to the final deployment method where as you wouldn't when using just the Django development server. 这意味着您将遇到与最终部署方法有关的问题,而在仅使用Django开发服务器时就不会。 So it is better to also incorporate some use of mod_wsgi-express into development if mod_wsgi will be your final target. 因此,如果mod_wsgi将是您的最终目标,则最好将一些对mod_wsgi-express并入开发中。 You can still get benefits of features such as automatic code reloading as mod_wsgi-express supports that, along with other features such as integrated Python debugger support etc. 您仍然可以获得诸如自动代码重新加载等功能的好处,因为mod_wsgi-express支持该功能,以及诸如集成Python调试器支持之类的其他功能。

The misconception about using mod_wsgi-express may come up because people think you have to do all this manual configuration to run it and thus it is too hard. 关于使用mod_wsgi-express的误解可能会出现,因为人们认为您必须完成所有手动配置才能运行它,因此这太难了。 You don't. 你不知道 Running mod_wsgi-express is no different to running other WSGI servers that can be run from the command line in that mod_wsgi-express will handle all the configuration for you. 运行mod_wsgi-express与运行其他可以从命令行运行的WSGI服务器没有什么不同,因为mod_wsgi-express将为您处理所有配置。 So no manual configuration of Apache is required. 因此,无需手动配置Apache。 It all happens automatically. 这一切都是自动发生的。

Until 4.5.8 is released and PyPi details are updated, the best place to see most up to date description of how to use mod_wsgi-express is at: 在发布4.5.8并更新PyPi详细信息之前,查看关于如何使用mod_wsgi-express最新描述的最佳位置是:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM