Use numpy & scipy in Azure web role Use numpy & scipy in Azure web role azure azure

Use numpy & scipy in Azure web role


I was able to add Numpy to my Azure Web App site. I believe my method also works for SciPy.

I am assuming you have a local repository (I am using GIT) and upload it to your Azure site. I am using Django and there is a file called requirements.txt in the base, which I bet is there for Flask also. Each line of this file contains a package that you want added to the installation.

At first I simply added a line with "Numpy" to it and Azure found a package and tried to install but this failed. So my next attempt I downloaded a "wheel" .whl package from this site:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

which includes all dependencies. Download the appropriate file (correct version of Python and 32 or 64 bit which can be chosen on Azure control panel) of the Numpy and SciPy wheel files and stick them into your base directory and add them to your project. Now a line to requirements.txt with just the file name, like this:

numpy-1.9.2+mkl-cp27-none-win32.whl

Commit and push to Azure and Voila! everything installs correctly. This also worked for me for the OpenCV wheel package at that site. Good luck!


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, ossys.path.append('D:\\home\\site\\wwwroot\\env\\Lib\\site-packages')