gpt4 book ai didi

python - Azure func 在使用 Core Tools 4.0.5030 的 M1 Mac 上启动失败

转载 作者:行者123 更新时间:2023-12-02 07:16:43 25 4
gpt4 key购买 nike

我尝试在 M1 Mac 上使用 python 的默认 azure HTTP 函数运行 func host start,但不断收到以下错误:

 *  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'.

我已尝试过此帖子中关于 github 的所有建议(例如使用 npm 安装 [email protected] 并复制 _cython)并且我尝试了不同的 python 版本(使用brew 和 conda 安装的 3.8、3.9、3.10),但我无法解决问题。

最佳答案

我找到了一种在 VsCode 中使用附加调试器的方法:

创建一个MakeFile:

FUNC_VERSION = $(shell func --version)
FUNC_PATH = $(shell realpath $$(which func))
FUNC_OSX_WORKER_PATH = $(dir $(FUNC_PATH))workers/python/3.10/OSX
FUNC_WORKER_CONFIG_JSON = $(dir $(FUNC_PATH))workers/python/worker.config.json
FUNC_OSX_WORKER_X64 = $(FUNC_OSX_WORKER_PATH)/X64
FUNC_OSX_WORKER_ARM64 = $(FUNC_OSX_WORKER_PATH)/Arm64
.PHONY: $(FUNC_OSX_WORKER_ARM64)
$(FUNC_OSX_WORKER_ARM64):
cp -r $(FUNC_OSX_WORKER_PATH)/X64 $(FUNC_OSX_WORKER_PATH)/Arm64
pip install grpcio --upgrade --target $@

.PHONY: $(FUNC_WORKER_CONFIG_JSON)
$(FUNC_WORKER_CONFIG_JSON):
cp $(FUNC_WORKER_CONFIG_JSON) $(FUNC_WORKER_CONFIG_JSON).bak
cat $(FUNC_WORKER_CONFIG_JSON) \
| jq '.description.supportedArchitectures |= .+ ["Arm64"]' \
> $(FUNC_WORKER_CONFIG_JSON).tmp
mv $(FUNC_WORKER_CONFIG_JSON).tmp $(FUNC_WORKER_CONFIG_JSON)

.PHONY: install_func_arm64_worker
install_func_arm64_worker: $(FUNC_OSX_WORKER_ARM64) $(FUNC_WORKER_CONFIG_JSON)

运行以下命令:

brew 安装 jq

make install_func_arm64_worker

最后启动调试器:“附加到Python函数”

原始来源: https://github.com/Azure/azure-functions-python-worker/issues/915#issuecomment-1495041653

关于python - Azure func 在使用 Core Tools 4.0.5030 的 M1 Mac 上启动失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75650871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com