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

M1 Mac使用Core Tools 4.0.5030启动Azure Func失败求助

M1 Mac运行Azure Python HTTP函数启动失败:Arm64架构不支持Python错误

问题描述

在M1 Mac上执行func host start运行默认Python版Azure HTTP函数时,持续触发Arm64架构不支持Python的错误,无法初始化Python工作器提供程序,导致主机启动失败。已尝试以下方案但未解决问题:

  • 通过npm安装azure-functions-core-tools@4.0.4483
  • 复制_cython文件
  • 更换多个Python版本(3.8、3.9、3.10,分别通过brew和conda安装)

错误详情

*  Executing task: . .venv/bin/activate && func host start 

Found Python version 3.9.16 (python3).

Azure Functions Core Tools
Core Tools Version:       4.0.5030 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.15.2.20177

[2023-03-06T12:16:54.298Z] Failed to initialize worker provider for: /usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/python
[2023-03-06T12:16:54.298Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2023-03-06T12:16:54.776Z] Failed to initialize worker provider for: /usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/python
[2023-03-06T12:16:54.776Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2023-03-06T12:16:54.931Z] A host error has occurred during startup operation 'a05c2dec-c700-4cb8-a8b0-e66cf535215d'.
[2023-03-06T12:16:54.931Z] Microsoft.Azure.WebJobs.Script: Did not find functions with language [python].
[2023-03-06T12:16:54.938Z] Failed to stop host instance '53731cda-f5d1-461a-b6b9-f627368ea3e0'.
[2023-03-06T12:16:54.938Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')
[2023-03-06T12:16:54.957Z] A host error has occurred during startup operation '057668d3-eee0-4a79-bf04-7a09d4bf398b'.
[2023-03-06T12:16:54.957Z] Microsoft.Extensions.DependencyInjection: Cannot access a disposed object.
[2023-03-06T12:16:54.957Z] Object name: 'IServiceProvider'.

解决方案

1. 用Rosetta 2兼容模式运行终端

M1 Mac的Arm64架构下,部分Azure工具对Python的支持需要通过Rosetta转译:

  • 找到「终端」应用,右键选择「显示简介」
  • 勾选「使用Rosetta打开」
  • 关闭当前终端,重新打开后执行func host start

2. 安装x86版本的Python和Core Tools

  • 安装x86版Python:
    在x86环境下通过brew安装Python:
    arch -x86_64 brew install python@3.9
    
    创建虚拟环境时指定x86版Python:
    arch -x86_64 python3.9 -m venv .venv
    source .venv/bin/activate
    
  • 安装x86版Azure Functions Core Tools:
    在x86环境下通过npm安装:
    arch -x86_64 npm install -g azure-functions-core-tools@4 --unsafe-perm true
    

3. 检查函数配置文件

确认local.settings.json中的FUNCTIONS_WORKER_RUNTIME设置为python:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
  },
  "ConnectionStrings": {}
}

4. 清理旧缓存并重新初始化

删除旧的Python工作器文件,重新初始化函数项目:

rm -rf /usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/python
arch -x86_64 func init --worker-runtime python

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 04:43:20