installed python 3.8.1 ,django 3.0.3 on windows server 2016 with wfastcgi and iam getting this error, cant find anything to fix it..
gave IIS AppPool\DefaultAppPool read&use permissions on python installation folder but it still does not work, somehow the handler can`t read it, but as much as i know the config seems to be right. Hope you can help me. Thanks in regards.
C:\inetpub\wwwroot -> web.conf
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\users\administrator\python38\python.exe|c:\users\administrator\python38\lib\site-packages\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<!-- Required settings -->
<add key="WSGI_HANDLER" value="web.wsgi.application" />
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\AddressLizenzbuch" />
<!-- Optional settings -->
<add key="DJANGO_SETTINGS_MODULE" value="web.settings" />
</appSettings>
</configuration>
C:\inetpub\wwwroot\AddressLizenzbuch\web\blog\static -> web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- Overrides the FastCGI handler to let IIS serve the static files -->
<handlers>
<clear/>
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
manage.py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
ERROR
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "c:\users\administrator\python38\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\users\administrator\python38\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\users\administrator\python38\lib\site-packages\wfastcgi.py", line 603, in get_wsgi_handler
handler = getattr(handler, name)
AttributeError: module 'web' has no attribute 'wsgi'
StdOut:
StdErr:
This should be an easy fix. Your Django project is the following structure
C:/inetpub/wwwroot/AddressLizenzbuch/web/web
with web.config
.
The problem is the extra directory AddressLizenzbuch
. REMOVE IT.
Your directory should look like C:/inetpub/wwwroot/web/web
.
The problem is that wfastcgi.py is looking for C:/inetpub/wwwroot/AddressLizenzbuch/web/wsgi.py
but that path obviously doesn't exist. Your config file should include this line after you remove that non-essential directory AddressLizenzbuch
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\web" />
To make this clear, your wsgi.py file should be located at C:\inetpub\wwwroot\web\web\wsgi.py
If you have any more questions, feel free to browse this project webproject on GitHub