The following forum(s) have migrated to Microsoft Q&A (Preview): Azure App Service - Web Apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Can I use Python 3+ with Azure Web SItes? RRS feed

  • Question

  • I was following the tutorial at : http://www.windowsazure.com/en-us/develop/python/tutorials/web-sites-with-django/ for setting up my Django web site on Azure. I didn't notice it when I first ran through the tutorial, but the tutorial specifies the soon to be deprecated python 2.7 runtime in it's instructions. I wrote the django app in 3.2 and can run it using 3.3, but don't really want to re-write it back down to 2.7. Is there a way to change the script handler to handle python 3+ instead of 2.7 or would I need to spin up a virtual machine?
    Sunday, October 13, 2013 5:10 PM

Answers

All replies

  • Hi,

    I do not familiar with Python and do not try this before, to use a different version, I would like to know do you try include it in the Git repository and configure the web site to use the interpreter instead of Python 2.7 interpreter already installed as suggested in the instructions?

    Best Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 14, 2013 9:19 AM
  • I tried adjusting the recommended path from D:/Python27 to D:/Python33 but that doesn't seem to work. How would i add it through git?
    Monday, October 14, 2013 12:21 PM
  • Hi,

    I afraid you will also need change other configurations to make the websites using Python33 instead. Hope this tutorial can help you.

    https://github.com/WindowsAzure/azure-content/blob/master/DevCenter/Python/Tutorials/web-sites-configuration.md

    Best Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ChargerIIC Tuesday, October 15, 2013 5:57 PM
    Monday, October 14, 2013 2:33 PM
  • I guess the question that this brings up is how do I include a copy of python 3.3 in my git? Do I need to create a directory using the python 33 source files or the exectuables from my /Python33/ folder on my local drive?
    Monday, October 14, 2013 4:01 PM
  • Hi,

    You might try the solution at http://stackoverflow.com/questions/8247605/configuring-so-that-pip-install-can-work-from-github, to install Python package from Git. Then configure for your website, something like:

    • Python script processor path: D:\python33\python.exe
    • Python FastCGI handler path: D:\python33\scripts\wfastcgi.py

    Hope this helps.

    Best Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 15, 2013 1:39 PM
  • After Adding the files and enabling logging I was able to find out I am now getting a 'FastCGI cannot be found' error. My configuration settings are below:

    WEBSITE_NODE_DEFAULT_VERSION 0.10.5
    DJANGO_SETTINGS_MODULE  DjangoApplication.settings
    PYTHONPATH              D:\home\site\wwwroot\DjangoApplication;
    WSGI_HANDLER            django.core.handlers.wsgi.WSGIHandler
    
    Handler Mappings
    *      D:\home\site\wwwroot\PythonCore\python.exe  D:\home\site\wwwroot\PythonCore\scripts\wfastcgi.py

    I noticed in your examples you had Python33 installed on D:\ . Is it possible for me to move files there or should I leave them in the site root?

    Tuesday, October 15, 2013 3:48 PM
  • You definitely can't write to d:\python33, so you'll need to bring needed bits into the site folder.
    Tuesday, October 15, 2013 4:00 PM
  • Look like I found the crux of the issue: the default WSGI has not been updated to Python 3 at all. Looks like I'll need to find an alternate wscgi handler.
    Tuesday, October 15, 2013 5:56 PM
  • Ok, here is one here that I just got from our Python expert. Can you give it a try? He wrote:

    "Here’s a version of wfastcgi that can at least server basic requests.  There’s still more testing and likely fixes but it might allow you to make sure basic things are working once applicationHost.config is fixed."

    Tuesday, October 15, 2013 6:49 PM
  • I discovered an issue (which will likely affect you) after handing that off to David and have a fixed version here: http://pastebin.com/SXKNQC9t

    It now also passes all of our test cases for both 3.3 & 2.7, so it should likely just work now.


    Dino

    Tuesday, October 15, 2013 9:03 PM
  • That definitey progressed things - I'm now getting a 500-Internal Server Error:

    D:\home\site\wwwroot\PythonCore\python.exe - The FastCGI process exited unexpectedly

    I can see it calling the right modules:

    <EventData>
      <Data Name="ContextId">{00000000-0000-0000-1B06-0080050000FF}</Data>
      <Data Name="OldHandlerName"></Data>
      <Data Name="NewHandlerName">FastCGI_houseofburt_3ca48f34-919c-46ca-9905-ade09d32a42a</Data>
      <Data Name="NewHandlerModules">FastCgiModule</Data>
      <Data Name="NewHandlerScriptProcessor">D:\home\site\wwwroot\PythonCore\python.exe|D:\home\site\wwwroot\PythonCore\Scripts\wfastcgi.py</Data>
      <Data Name="NewHandlerType"></Data>
     </EventData>

    But I also see a bunch of these in the xml:

    <Opcode>MODULE_PRECONDITION_NOT_MATCH</Opcode>

    Things seem to go wrong around here:

    133. NOTIFY_MODULE_START ModuleName="HttpRedirectionModule", Notification="MAP_REQUEST_HANDLER", fIsPostNotification="false" 22:01:00.349
    134. NOTIFY_MODULE_END ModuleName="HttpRedirectionModule", Notification="MAP_REQUEST_HANDLER", fIsPostNotificationEvent="false", NotificationStatus="NOTIFICATION_CONTINUE" 22:01:00.349
    135. NOTIFY_MODULE_START ModuleName="FastCgiModule", Notification="EXECUTE_REQUEST_HANDLER", fIsPostNotification="false" 22:01:00.349
    136. SET_RESPONSE_ERROR_DESCRIPTION

    Warning
    ErrorDescription="D:\home\site\wwwroot\PythonCore\python.exe - The FastCGI process exited unexpectedly" 22:01:00.380
    137. MODULE_SET_RESPONSE_ERROR_STATUS

    Warning
    ModuleName="FastCgiModule", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="500", HttpReason="Internal Server Error", HttpSubStatus="0", ErrorCode="3221225781", ConfigExceptionInfo=""



    • Edited by ChargerIIC Wednesday, October 16, 2013 1:18 AM Cut out extra text
    Tuesday, October 15, 2013 9:40 PM