python的web库,Web Job上的Python库

My goal is to run a python script that uses Anaconda libraries (such as Pandas) on Azure WebJob but can't seem to figure out how to load the libraries.

I start out just by testing a simple azure blob to blob file copy which works when run locally but hit into an error "ImportError: No module named 'azure'" when ran in WebJob.

example code:

from azure.storage.blob import BlockBlobService

blobAccountName =

blobStorageKey =

containerName =

blobService = BlockBlobService(account_name=blobAccountName,

account_key=blobStorageKey)

blobService.set_container_acl(containerName)

b = blobService.get_blob_to_bytes(containerName, 'file.csv')

blobService.create_blob_from_bytes(containerName, 'file.csv', b.content)

As you can see, I can't even get Azure SDK libraries to run... let alone Anacondas :-(

Hence I would appreciate if someone could guide me step-by-step...

How do I run a python script that requires external libraries such as Anaconda (and even Azure SDK). How do I "pip install" these stuff for a WebJob?

Thanks!!!

解决方案

It seems like you've kown about deployment of Azure WebJobs, I offer the below steps for you to show how to load external libraries in python scripts.

Step 1 :

Use the virtualenv component to create an independent python runtime environment in your system.Please install it first with command pip install virtualenv if you don't have it.

If you installed it successfully ,you could see it in your python/Scripts file.

5942f5ea18420404f38453da41f3ad3f.png

Step2 : Run the commad to create independent python runtime environment.

71f7dd4e81cd7d5e16342d882d72ae46.png

Step 3: Then go into the created directory's Scripts folder and activate it (this step is important , don't miss it)

ac8e7a6e777d90f73c4fddcf2ae0d6ff.png

Please don't close this command window and use pip install to download external libraries in this command window.

IHAqU.png

Step 4:Keep the Sample.py uniformly compressed into a folder with the libs packages in the Libs/site-packages folder that you rely on.

8cea6ba9965d2c92e079447115130273.png

Step 5:

Create webjob in Web app service and upload the zip file,then you could execute your Web Job and check the log

6d9e66c9dfc167b07b0bc77fbe48aee9.png

In addition, if you want to use the modules in Anaconda, please download them separately. There is no need to download the entire library.

Hope it helps you.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值