iamsirjayesh iamsirjayesh - 1 year ago 153
Python Question

install python modules in azure

I am trying to run a python script using WebJob in Azure. But I am getting module is not found. When I tried to run the pip command it says Access denied

Also I tried to change the folder permission using

. But it gives:

[11/11/2016 18:17:35 > e1c140: ERR ] chmod: changing permissions of 'D:\Python27\Lib\site-packages/setuptools/....pyc': Permission denied

[11/11/2016 18:17:38 > e1c140: INFO] error: could not create 'D:\Python27\Lib\site-packages\mpns': Access is denied

I even tried

def install(pack):
pip.main(['install', "--user", pack])

Is there option to install the modules
(beautifulsoup, mechanize , python-mpns)

I manually copied the modules using the FTP connection to the folder and tried to execute
python setup.py install
. Even this fails.

Answer Source

So this is what worked for me (for Azure Functions but they are similar to WebJob and they even use the same SDK). I've copied wheel package of the module in question to the same github where the Function code was and added following code to the Function initialization:

import os,pip,sys,time
 import pyodbc
 package = 'pyodbc-3.0.10-cp27-none-win32.whl'
 pip.main(['install', '--user', package])
 raise ImportError('Restarting')

You could obviously copy wheel package any other way, I just found this way convenient enough.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download