2

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 os.chmod . 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 --user option.

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.

Hunterr
  • 553
  • 1
  • 8
  • 28

1 Answers1

4

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
try:
 import pyodbc
except:
 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.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • you mean, first copy the wheel package to the location where the `.py` file is uploaded, and from the same file call that wheel? – Hunterr Nov 12 '16 at 13:57
  • let me give a try, and what for the zipped modules? – Hunterr Nov 12 '16 at 13:59
  • i just changed the package name to `package.zip` and installed the same way, all of them got installed. And my job is running :) Thanks a lot for the solution :) – Hunterr Nov 12 '16 at 15:05