zin*_*rim 5 python azure-functions apple-silicon
跑步
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
Run Code Online (Sandbox Code Playgroud)
在 vscode 中
pyenv shell 3.9.12
Requirement already satisfied: azure-functions in ./.venv/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (1.12.0)
WARNING: You are using pip version 21.2.4; however, version 22.3 is available.
You should consider upgrading via the '/Users/deniz/Library/CloudStorage/OneDrive-DualCitizen/Dev/2ndfunction/.venv/bin/python -m pip install --upgrade pip' command.
* Terminal will be reused by tasks, press any key to close it.
* Executing task: . .venv/bin/activate && func host start
Found Python version 3.9.10 (python3).
Azure Functions Core Tools
Core Tools Version: 4.0.4829 Commit hash: N/A (64-bit)
Function Runtime Version: 4.11.2.19273
[2022-10-23T09:38:17.290Z] Failed to initialize worker provider for: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4829/workers/python
[2022-10-23T09:38:17.290Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2022-10-23T09:38:17.818Z] Failed to initialize worker provider for: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4829/workers/python
[2022-10-23T09:38:17.818Z] Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
[2022-10-23T09:38:17.957Z] A host error has occurred during startup operation '29ac434c-0276-4c0b-a85f-c9e4863577dc'.
[2022-10-23T09:38:17.957Z] Microsoft.Azure.WebJobs.Script: Did not find functions with language [python].
[2022-10-23T09:38:17.964Z] Failed to stop host instance '3d492f60-0fd3-48dd-bce0-d7cc99da71c8'.
[2022-10-23T09:38:17.964Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.
Value cannot be null. (Parameter 'provider')
[2022-10-23T09:38:17.986Z] A host error has occurred during startup operation '1327f3e2-25e9-4318-bfea-0bac013aff02'.
[2022-10-23T09:38:17.986Z] Microsoft.Extensions.DependencyInjection: Cannot access a disposed object.
[2022-10-23T09:38:17.986Z] Object name: 'IServiceProvider'.
* Terminal will be reused by tasks, press any key to close it.
Run Code Online (Sandbox Code Playgroud)
我尝试了很多事情,包括:
python3 -m venv .venv/我还尝试应用此处概述的 Rosetta 修复 程序How to run the Homebrew installer under Rosetta 2 on M1 Macbook
但没有成功。我怎样才能解决这个问题?
我在 M1 Mac 上不断遇到 python 问题,直到我完全使用命令行上的 Rosetta。为此,我做了以下事情:
\nsoftwareupdate --install-rosetta\nRun Code Online (Sandbox Code Playgroud)\ni386在您发出命令时显示arch:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"\nRun Code Online (Sandbox Code Playgroud)\nbrew install --cask miniconda\nRun Code Online (Sandbox Code Playgroud)\nazure:conda create -n azure python=3.9\nRun Code Online (Sandbox Code Playgroud)\n然后激活环境:
\nconda activate azure\nRun Code Online (Sandbox Code Playgroud)\n从现在开始,您就拥有了一个功能齐全的 i386 Python 系统。这解决了我在 M1 Mac 上使用 Azure、Numpy、Pandas 等时遇到的所有问题。
\n| 归档时间: |
|
| 查看次数: |
3253 次 |
| 最近记录: |