2016-10-17 5 views
1

Ich habe eine virtualenv eingerichtet, um einen Flaschen-Server zu betreiben. Ich bin den Schritten gefolgt, um wfastcgi einzurichten, um mit iis zu arbeiten. Es scheint zu funktionieren, da ich auf die Python-App zugreifen kann, aber ein Python-Fehler-Stack wird gedruckt.Flask App auf IIS mit wfastcgi virtualenv - Paket nicht gefunden

Fehler beim WSGI Handler Lesen:

Traceback (most recent call last): 
File "c:\python27\lib\site-packages\wfastcgi.py", line 793, in main 
env, handler = read_wsgi_handler(response.physical_path) 
File "c:\python27\lib\site-packages\wfastcgi.py", line 635, in read_wsgi_handler 
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) 
File "c:\python27\lib\site-packages\wfastcgi.py", line 618, in get_wsgi_handler 
raise ValueError('"%s" could not be imported%s' % (handler_name, last_tb)) 
ValueError: "flask_app.application()" could not be imported: Traceback (most recent call last): 
File "c:\python27\lib\site-packages\wfastcgi.py", line 602, in get_wsgi_handler 
handler = __import__(module_name, fromlist=[name_list[0][0]]) 
File ".\flask_app.py", line 7, in <module> 
from app import app as application 
File ".\app\__init__.py", line 67, in <module> 
from flask_restless import APIManager 
ImportError: No module named flask_restless 

Ich denke, dies mit der Art und Weise zu tun hat, ich flask_restless installiert. Ich habe es mit

pip install -e git://github.com/jfinkels/flask-restless.git#egg=flask_restless 

installiert, die nicht erscheint, um Flask_Restless zum Lib/Site-Packages-Verzeichnis hinzuzufügen. Aber es ist kein Problem, wenn ich die App manuell ausführe.

Hier ist meine web.config:

<configuration> 
    <system.webServer> 
    <handlers> 
     <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python27\python.exe|C:\Python27\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" /> 
    </handlers> 
    </system.webServer> 

    <appSettings> 
    <!-- Required settings --> 
    <add key="WSGI_HANDLER" value="flask_app.application()" /> 
    <add key="PYTHONPATH" value="C:\www\flask_app\virtualenv\src;C:\www\flask_app\virtualenv\Lib\site-packages;C:\www\flask_app\app" /> 

    <!-- Optional settings --> 
    <add key="WSGI_LOG" value="C:\inetpub\logs\wsgi.log" /> 
    <add key="WSGI_RESTART_FILE_REGEX" value=".*((\.py)|(\.config))$" /> 
    </appSettings> 
    </configuration> 

Und mein flask_app.py ist wie folgt:

this_file = 'C:/www/flask_app/virtualenv/Scripts/activate_this.py' 
with open(this_file) as f: 
    code = compile(f.read(), this_file, 'exec') 
    exec(code) 


from app import app as application 

Antwort

2

Ich habe keine Ahnung, ob dies richtig ist, aber es hat für mich zu arbeiten. Es gab ein paar verschiedene Pakete, die wastcgi nicht finden konnte, außer Flasch-unruhig. Um das zu lösen, aktivierte ich das virtuelle env und druckte meine sys.path Variable aus. Ich habe dann alle Pfade in den PYTHONPATH Schlüssel in meiner web.config Datei kopiert.

Also meine web.config sieht nun wie folgt aus:

<configuration> 
<system.webServer> 
<handlers> 
    <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python27\python.exe|C:\Python27\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" /> 
</handlers> 
</system.webServer> 

<appSettings> 
<!-- Required settings --> 
<add key="WSGI_HANDLER" value="flask_app.application" /> 
<add key="PYTHONPATH" value="C:/www/Lib/site-packages;c:/python27/lib/site-packages/fabric-1.10.2-py2.7.egg;c:/python27/lib/site-packages/paramiko-1.16.0-py2.7.egg;c:/python27/lib/site-packages/ecdsa-0.13-py2.7.egg;c:/python27/lib/site-packages/pycrypto-2.6.1-py2.7-win32.egg;c:/python27/lib/site-packages/psycopg2-2.5.2-py2.7.egg;C:/Windows/system32/python27.zip;c:/python27/DLLs;c:/python27/lib;c:/python27/lib/plat-win;c:/python27/lib/lib-tk;c:/python27;c:/python27/lib/site-packages;C:/www/flask_app/virtualenv/src;C:/www/flask_app/virtualenv/Lib/site-packages;C:/www/flask_app/app;C:\www\flask_app\virtualenv\Lib\site-packages\Flask_Restless-1.0.0b1-py2.7.egg" /> 

<!-- Optional settings --> 
<add key="WSGI_LOG" value="C:/www/flask_app/flask.log" /> 
<add key="WSGI_RESTART_FILE_REGEX" value=".*((\.py)|(\.config))$" /> 
</appSettings> 
</configuration> 
+1

Mit der Taste = „PYTHONPATH“ ein Problem behoben Einstellung Ich habe seit Wochen mit zu kämpfen. Vielen Dank! – Ari

Verwandte Themen