简体   繁体   中英

Cant install mod_wsgi in Django on Mac

I've been having trouble installing mod_wsgi on Django. This is the traceback for the terminal. I'm using 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

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.

Even so, in mod_wsgi 4.5.8 there is a workaround that allows pip install mod_wsgi to still work. 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.

Right at this instant in time 4.5.8 isn't released though but will be in the next day or so. In the interim you can install from the GitHub repository by running:

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. One of the main points of mod_wsgi-express is to make it very easy to use for development, including with 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. 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. So it is better to also incorporate some use of mod_wsgi-express into development if mod_wsgi will be your final target. 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.

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. 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. So no manual configuration of Apache is required. 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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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