简体   繁体   中英

Specify Python version in Microsoft Azure WebJob?

How can I select which Python version to use for a WebJob on Microsoft Azure?

When I do print(sys.version) I get 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)]

Where can I specify another version? I would like to use Python 3 for some jobs. I have tried adding runtime.txt reading python-3.4 to the root path, but it had no effect.

Also if you wanna run different python versions in the same site, you can always drop a run.cmd that calls the right version of python for you. They are installed in D:\\Python34 and D:\\Python27

Azure WebJobs run in the context of your App Service plan.

By default, the python version is 2.7 (as you've discovered). To change this, you'll need to look at the settings for your App Service plan and change the python version.

Here's an example, from one of my App Service plans. Initially, it was unset, but I changed it to 3.4:

python版本设置

I also created a test webjob in python:

import sys
print (sys.version)

I ran it before changing the python settings:

python 2.7输出

I then changed the python version to 3.4 in the App Service settings, and ran it again:

python 3.4输出

Beside David Makogon's answer, we also can configure the python version in current Azure manage portal .

In the manage portal of your Azure Web Apps, in configure tab, under general section, we can specify the python version which will be configured in your Web App runtime. Restart your site after your saving your configuration. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM