You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

本地运行Python Azure函数报错:WorkerConfig for runtime: python not found

解决本地运行Python Azure函数时的"WorkerConfig for runtime: python not found"错误

本地运行Python Azure函数时出现如下错误:

[2024-09-05T15:23:14.773Z] A host error has occurred during startup operation 'dac4260d-fa20-49b8-a225-97dc6b2aceab'.
[2024-09-05T15:23:14.777Z] Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: python not found.
[2024-09-05T15:23:14.790Z] Failed to stop host instance '4975e599-c38c-4003-a5ab-30f8005eef48'.
[2024-09-05T15:23:14.793Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')

尝试以下解决方案:

  • 验证版本兼容性
    运行 func --version 查看Azure Functions Core Tools版本,python --version 查看Python版本。Core Tools v4仅支持Python 3.8-3.11,若版本不匹配,要么升级/降级Core Tools,要么调整Python版本。

  • 明确指定Python运行时路径
    在项目根目录的local.settings.json中添加Python可执行文件路径:

    {
      "IsEncrypted": false,
      "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "python",
        "AzureWebJobsStorage": "UseDevelopmentStorage=true"
      },
      "PYTHON_EXE_PATH": "./.venv/Scripts/python.exe" // Windows环境;Linux/macOS改为./.venv/bin/python
    }
    

    同时确保Python安装路径已加入系统环境变量PATH。

  • 重新初始化函数项目配置
    删除项目根目录下的.vscode/settings.json,在VS Code中重新选择venv环境的Python解释器,然后执行 func init --worker-runtime python --force 重新初始化项目,覆盖可能损坏的配置文件。

  • 修复Azure Functions Core Tools安装
    卸载当前Core Tools,从官方渠道重新安装对应版本,安装过程中勾选"Add to PATH"选项,安装完成后重启VS Code再尝试运行函数。

  • 确保虚拟环境正确激活
    在终端手动激活venv:

    • Windows:.venv\Scripts\activate
    • Linux/macOS:source .venv/bin/activate
      激活后再执行 func start 启动函数。

内容的提问来源于stack exchange,提问作者TheSingingSDK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 20:12:44