Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Installing Python packages in Azure App Services is little tricky using pip. In this blog, I would provide best practice to do that.
Pip Install on Azure App Services might fail because
Below is one such common scenario
building 'Crypto.Random.OSRNG.winrandom' extension
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from https://aka.ms/vcpython27
It's recommend to use wheels for installing Python dependencies. Many of the popular modules already provide wheel files listed in PyPI.
Let's say if I want to install below list of Python modules
django<2
pycrypto==2.6.1
pandas==0.18.1
numpy==1.11.1
I'm using Python 3.5.2 x64
for this blog. So i will create wheel files for Python35 x64.
Note : You don't have to create wheels for all the Python modules. Do this only for modules which have trouble installing in Azure App Services
python35 x64
installed in my local environment @ C:\Python35 folder > C:\Python35\python.exe -m pip install wheel
> C:\Python35\python.exe -m pip wheel -r requirements.txt -w wheelhouse
Above step would have created a wheelhouse folder with wheel files for modules listed in requirements.txt file (In my cases it created wheel files for Python35 arch as you can see in file names)
Default Python/Pip versions on Azure Web Apps are little old (as of 01/17 -This might change in future). Older version of Python/Pip have few known issues during deployment/run-time.
Follow Below steps to update Python version on your web app.
For this blog I'm choosing Python 3.5.2 x64
, It would install new version of python @ D:\home\Python35
--find-links wheelhouse
Your_app_name
.scm.azurewebsites.net/DebugConsole) > D:\home\Python35\python.exe -m pip install --upgrade -r requirements.txt
D:\home\Python35\Lib\
folderYou might have different path for python.exe depending on python version you are using.
If you are using Deployment script, Include below line of code in deploy.cmd
:: 2. Install packages
echo Pip install requirements.
D:\home\Python35\python.exe -m pip install --upgrade -r requirements.txt
IF !ERRORLEVEL! NEQ 0 goto error
For more details refer Django app with HttpPlatformHandler in Azure App Services - Windows
As I have mentioned earlier, running above command would install modules
@ D:\home\Python35\Lib\
folder.
D:\home\Python35\python.exe -m pip install --upgrade -r requirements.txt -t D:\home\site\wwwroot\pymodules
Above Command would install Python modules @ D:\home\site\wwwroot\pymodules
folder
I have seen few wheel files/Python modules having trouble installing with older version of Pip/Python. Try with newer version's of Python/pip if you have any issues.
Anonymous
July 05, 2015
Thanks for the post. Saved me few hours :)
Anonymous
September 07, 2016
I have been struggling with --find-links for an entire day, and I will be very grateful if sb could help me out here.I have been developing using Azure Storage( the most recent version) and it requires cryptograph, which requires cffi, idna, etc...However, when I try to test it against Azure Webapp, the deployment failes, saying 'error : unable to find vcvarsall.bat'With some research, I figured putting --find-links wheelhouse at the top of my requirements.txt and have wheels(cffi-1.8.2-cp26-cp26m-win32.whl (md5) and cryptography-1.5-cp26-cp26m-win32.whl (md5)) located at wheelhouse folder in the root. This was not helping at all, and I was running into same problems.I tried --no-index and it gives "Could not find any downloads that satisfy the requirement cffi==1.8.2". Somebody says if I want to use --no-index, then I should have all wheels located in wheelhouse; otherwise, i will get that error.With this, I would like to use my wheels for cffi and cryptograph and the rest download from pypi. Anyone have any clue...? HELP!
Anonymous
September 23, 2016
Thanks for the post - but I ran into an issue. First, the .whl I got wasn't named "pycrypto-2.6.1-cp27-none-win32.whl" like yours, it was named "pycrypto-2.6.1-cp27-cp27m-win32.whl". At first it didn't work, but by renaming it it did the trick, installed it and said "deployment successful", no errors, all requirements satisfied - including pycrypto.I can indeed find a pycrypto-2.6.1.dist-info folder inside wwwroot\env\Lib\site-packages. It's filled with files such as "WHEEL", "RECORD", "METADATA", which is unusual but I'm guessing it's binary.The problem is, this is what my python code tells me:"ImportError: No module named Crypto.PublicKey"
Anonymous
February 24, 2017
hi When I try to use D:\home\Python35\python.exe -m pip install --upgrade -r requirements.txt this command it says access is denied in azure console. How can I sort this out? Thanks
Anonymous
April 21, 2017
Hi, i ran into some problems, maybe you can help me?https://social.msdn.microsoft.com/Forums/azure/en-US/313d4b2e-78bb-45e0-9805-063185b48685Thanks in advance.
Anonymous
June 22, 2017
I'm struggling to make the Extensions for an app. The code has dependency for Exifread. Followed this article and see all the libs in the environment. It still keeps loading version 2.7 instead of version 3.6.1...I couldn't find a place to update PYTHONPATH on the portal. Tried it in web.config and it yielded same result.... the last mile for me to complete the app. Appreciate any help.Python Path:[u'D:\home\site\wwwroot\env\Lib\site-packages', '.', 'D:\Windows\SYSTEM32\python27.zip', 'D:\Python27\DLLs', 'D:\Python27\lib', 'D:\Python27\lib\plat-win', 'D:\Python27\lib\lib-tk', 'D:\Python27', 'D:\Python27\lib\site-packages', 'D:\home\site\wwwroot\env']
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in