When attempting to use Python 3.5 with my Django App, I get a 500 error with the message, "An unknown FastCGI error occurred". I have no problems with Python 3.4 -- works like a charm. Here is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<!--<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="django.core.wsgi.get_wsgi_application()" />-->
<!--<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS" value="c:\users\aarsan\projects\condofront\env\Scripts\python.exe" />-->
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="PYTHONPATH" value="c:\users\aarsan\projects\condofront" />
<add key="DJANGO_SETTINGS_MODULE" value="condofront.settings_dev" />
<!--<add key="WSGI_LOG" value="c:\LogFiles\wfastcgi.log"/>-->
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler"
path="handler.fcgi"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\users\aarsan\appdata\local\programs\python\python35\python.exe|c:\users\aarsan\appdata\local\programs\python\python35\lib\site-packages\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
<rewrite>
<rules>
<rule name="Static Files" stopProcessing="true">
<conditions>
<add input="true" pattern="false" />
</conditions>
</rule>
<rule name="Configure Python" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
I read somewhere (can't find the source now) that wfastcgi 2.2.1 was not compatible with Python 3.5 but I don't know if that is correct. If I can get some assistance in trying to setup some type of logging for this, it would be very much appreciated.
There's a fix that went in specifically for 3.5: https://github.com/Microsoft/PTVS/commit/ade355a7fb67d2ee703b1db9139406c7140ef63a#diff-22cd7621487a2d190485ec8d53b6c81e
maybe try that version?
@huguesv it looks like that is the version I am running. I don't seem to have a problem enabling / disabling the handler. I just receive the 500 error. Do you know of a way to troubleshoot this?
I don't know if the commented out WSGI_LOG there means you've tried it and didn't get any useful info out of that log, but if you haven't tried, that would be the thing to do next.
Yeah, the WSGI_LOG key seems to either not work or nothing gets logged. I am trying this in a virtual environment now to see if that helps at all. maybe app pool not having access to wfastcgi is the issue?
So seems like a permissions issue, I think I tried giving full permissions to the virtual environment but that didn't work, but I changed the app pool account from ApplicationPoolIdentity to LocalSystem and it all started working. I don't have this problem in Python 3.4.
If it's permissions, you may also need to set permissions for the base environment as well, since the virtual environment requires that to work properly.
As an alternative, you could use the Nuget packages to get a full distro of Python and use that for deployment instead of a virtual environment.
I'd also suggest looking at our guidance at https://aka.ms/PythonOnAppService as it relates to the web.config file, since we're now recommending much simpler files then we'd generate in the past. (Some of that page relates specifically to Azure, but a lot of it is specific to IIS and so applies to local/on-prem servers too.)
@aarsan Many many many thanks for your information. You save my day!
So seems like a permissions issue, I think I tried giving full permissions to the virtual environment but that didn't work, but I changed the app pool account from ApplicationPoolIdentity to LocalSystem and it all started working. I don't have this problem in Python 3.4.
Thank you bro. You saved my life :))
it saved my life too, ty
I would never have figured out myself!
Thanks a Lot !!!!
It works only on local machine..
For other machines in Network, I have to downgrade python
OMG,@aarsan Many many many thanks for your information. It works. You save my life!
Por acá dejo un tutorial donde explico como realizar esta operación: https://github.com/bitcubico/python-tutorial/blob/master/IIS-CONFIG.md
Most helpful comment
So seems like a permissions issue, I think I tried giving full permissions to the virtual environment but that didn't work, but I changed the app pool account from ApplicationPoolIdentity to LocalSystem and it all started working. I don't have this problem in Python 3.4.