user1683766
user1683766

Reputation: 189

Getting mod_wsgi to work with Python 2.7/Apache on Windows Server 2012; cannot load module

I successfully installed mod_wsgi via pip install mod_wsgi on Windows. However, when I copy the output of mod_wsgi-express module-config into my httpd.conf and try to start the httpd, I get the following error:

httpd.exe: Syntax error on line 185 of C:/path/to/httpd.conf: Cannot load c:/path/to/venv/Lib/site-packages/mod_wsgi/server/mod_wsgi.pyd into server

This is already after correcting the pasted output of module-config, as it was .../venv/lib/site-packages/mod_wsgi/server/mod_wsgiNone (note the "None"). I changed the "None" to ".pyd" as this is the correct path.

I already tried to install it outside the virtual env (Python being at C:\Python27), but it didn't make a difference -> same error.

I also tried to uninstall/re-install mod_wsgi. I had one failed install as Microsoft Visual C++ Compiler for Python 2.7 (Version 9.0.0.30729) was not present. After that installation, the mod_wsgi always installed OK.

The apache (Apache/2.4.27 (Win32)) comes from the xampp package and starts without issues when I remove the added lines for wsgi.

I need to use Python 2.7 because of a third-party module. So going for 3.x is unfortunately not an option at the moment.

Exact Python version is 2.7.13 (32-bit).

For completeness, the output of module-config is:

LoadModule wsgi_module "c:/www/my_project/venv/lib/site-packages/mod_wsgi/server/mod_wsgiNone" WSGIPythonHome "c:/www/my_project/venv"

Update: tried one more thing:

Still the same error...

Upvotes: 0

Views: 1301

Answers (1)

user1683766
user1683766

Reputation: 189

The issue was that the Apache was built with VC14, but Python 2.7 naturally with VC9. Installing an Apache built with VC9 solved my issue.

Upvotes: 1

Related Questions