Use numpy & scipy in Azure web role

后端 未结 2 994
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 19:32

I\'m considering using an Azure web site for a Python project with Flask. I already have a test site running with this configuration. I\'m using cPhyton 2.7; IronPhyton is a

2条回答
  •  误落风尘
    2020-12-06 19:40

    OnTheContrary's answer is excellent, but as of this writing, the wheels on the pythonlibs website cannot be deployed to an Azure Web App exactly as provided. Fortunately, renaming the wheel files seems to resolve the issue for numpy, pandas, and scipy.

    Currently, when I run import pip; print(pip.pep425tags.get_supported()) from a Python 3.4 WebJob I get the following output:

    [09/28/2016 17:08:30 > 775106: INFO] [('cp34', 'none', 'win32'),
    ('cp34', 'none', 'any'), ('cp3', 'none', 'any'), ('cp33', 'none', 'any'),
    ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', 'any'),
    ('py34', 'none', 'any'), ('py3', 'none', 'any'), ('py33', 'none', 'any'),
    ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
    

    The numpy-1.11.2rc1+mkl-cp34-cp34m-win32.whl file from pythonlibs would parse to ('cp34', 'cp34m', 'win32') and therefore would not be supported. Fortunately, the wheel can be deployed by renaming it to numpy-1.11.2rc1+mkl-cp34-none-win32.whl. Similar modifications work for the pandas and scipy packages.

    Also, a few notes of clarification regarding OnTheContrary's suggested approach:

    • More information on creating a git repo for Web App deployment can be found here. You can add the wheels to the base directory of your git repo and then include each file name in the requirements.txt file.
    • You will need to ensure that the Web App's site-packages folder is on the system path before you try to import the packages in your WebJob. You can do this by adding the following lines at the start of your WebJob's run.py file:

      import sys, os
      sys.path.append('D:\\home\\site\\wwwroot\\env\\Lib\\site-packages')
      

提交回复
热议问题