11

I am trying to install mod_wsgi in Windows 10.

The command pip install mod_wsgi is giving me error,

RuntimeError: No Apache installation can be found. Set the MOD_WSGI_APACHE_ROOTDIR environment to its location.

My Apache dir is F:\Apache24\.

My question is, how to setup MOD_WSGI_APACHE_ROOTDIR environment ?

Thanks, Sambhav

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
Kumar Sambhav Pandey
  • 1,713
  • 4
  • 22
  • 33
  • Where is you wsgi file? – ultrajohn Feb 19 '17 at 05:01
  • 1
    pip install mod_wsgi doesn't require prior download of the file. It does it for you. As @Alisdair suggested, I ran the command `set "MOD_WSGI_APACHE_ROOTDIR=F:\Apache24"` and then executed `pip install mod_wsgi` and it crossed that point but now it is giving me `Unable to find vcvarsall.bat`. Any idea about error ? Thanks, Sambhav – Kumar Sambhav Pandey Feb 19 '17 at 05:57
  • 1
    Don't use backslashes in path when setting that environment variable. Have had some reports that backslash doesn't work. use ``set "MOD_WSGI_APACHE_ROOTDIR=F:/Apache24"`` if using CMD shell. It is probably related to how Windows shell handles backslash escapes. Use forward slash and avoid any issues. – Graham Dumpleton Feb 19 '17 at 06:51
  • 1
    BTW, steps for what you need to do after installation are explained in http://stackoverflow.com/a/42307082/128141 – Graham Dumpleton Feb 19 '17 at 06:55

2 Answers2

17

Referring to the docs at http://modwsgi.readthedocs.io/en/develop/release-notes/version-4.5.12.html should help you.

In Short:

By default the installation looks for Apache in C:\Apache24, C:\Apache22 and C:\Apache2, as your installation is none of these you need to set the environment variable MOD_WSGI_APACHE_ROOTDIR to the path you have installed it to.

On your system you would do this by running this in your command prompt:

set "MOD_WSGI_APACHE_ROOTDIR=F:\Apache24"

Which sets the variable, and then you can run the pip command (in the same command prompt):

pip install mod_wsgi


To read more about the set command run set /? in command prompt.

  • Thank you for the quick response. Need further help, After executing the above commands I am getting `Unable to find vcvarsall.bat`. Could you please help in this as well ? Thank you, Sambhav – Kumar Sambhav Pandey Feb 19 '17 at 05:53
  • 1
    vcvarsall.bat is part of the Microsoft Visual C++ Compiler, mod_wsgi must be trying to compile some C code on installation, if this is Python 2.7 just use the Microsoft Visual C++ Compiler for Python 2.7: https://www.microsoft.com/en-au/download/details.aspx?id=44266 Or for Python 3.5 you'll need to install Visual Studio 2010. – Alisdair Robertson Feb 19 '17 at 06:44
  • Right, I am using Python 3.5. now to resolve this issue I am installing VC++ 2008 express. Thanks again, Sambhav – Kumar Sambhav Pandey Feb 19 '17 at 06:46
  • 2
    If you are using Python 3.5, you should not be using VC++ 2008. See https://wiki.python.org/moin/WindowsCompilers You want 'Microsoft Visual C++ 14.0 standalone'. – Graham Dumpleton Feb 19 '17 at 06:50
  • Thanks @GrahamDumpleton for pointing in the correct direction, I will try the same. Regards, Sambhav – Kumar Sambhav Pandey Feb 19 '17 at 09:31
  • Just an update, Finally was able to install it. The last issue came about the unresolved external libraries and symbols which was because I was accidently running 32-bit Python instead of 64 bit. So installed 64 bit and after that installation went successfully. Thank you for help Alisdair Robertson and @GrahamDumpleton for the help. Regards, Sambhav – Kumar Sambhav Pandey Feb 20 '17 at 12:47
  • I have installed the apache through wamp installation. Can someone direct me where's is the Apache installation directory? I have tried **wamp/bin/apache** **wamp/bin/apache/apache2.4.23** **wamp/www** None worked. – Siraj Alam Mar 04 '18 at 10:36
  • You may run into problems later if you used `set "MOD_WSGI_APACHE_ROOTDIR=F:\Apache24"`. To be safe, use a forward slash: `set "MOD_WSGI_APACHE_ROOTDIR=F:/Apache24"` – user3187724 Oct 12 '20 at 07:51
1

If pip install mod_wsgi cannot find the apache root dir and asked to set (MOD_WSGI_APACHE_ROOTDIR) env variable.

set "MOD_WSGI_APACHE_ROOTDIR=F:\Apache24"

does not work in pycharm terminal (powershell), use below instead (verify path)

$env:MOD_WSGI_APACHE_ROOTDIR = "C:\wamp64\bin\apache\apache2.4.51"
alsaleem
  • 347
  • 3
  • 16