为什么pythonazure函数不能在本地运行?

2024-10-03 15:26:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用VSCode在本地运行pythonazure函数,但它几乎立即关闭了自己。在

我已经按照教程创建了最简单的示例函数,但是我相信我的机器上有一些配置错误。在

几乎在启动函数之后,我看到了以下内容

[9/1/2019 4:52:07 PM] Found the following functions:
[9/1/2019 4:52:07 PM] Host.Functions.HttpTriggerTest
[9/1/2019 4:52:07 PM]
[9/1/2019 4:52:07 PM] Host initialized (573ms)
[9/1/2019 4:52:07 PM] Host started (590ms)
[9/1/2019 4:52:07 PM] Job host started
[9/1/2019 4:52:07 PM] python: can't open file 'C:\Users\First': [Errno 2] No such file or directory
[9/1/2019 4:52:07 PM] python: can't open file 'C:\Users\First': [Errno 2] No such file or directory
[9/1/2019 4:52:07 PM] Starting language worker process:python  C:\Users\First Last\.vscode\extensions\ms-python.python-2019.3.6558\pythonFiles\ptvsd_launcher.py --default --host 127.0.0.1 --port 9091 --wait "C:\Users\First
Last\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\worker.py" --host 127.0.0.1 --port 64975 --workerId e9dc059f-128f-4e11-8363-797b4f1eeb1b --requestId c857107a-6b99-4d5a-9b71-d27827bfcad3 --grpcMaxMessageLength 134217728
[9/1/2019 4:52:07 PM] python process with Id=20920 started
Hosting environment: Production
Content root path: C:\file_location\Dev\PythonDev\MyAzureFunctions
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

Http Functions:

        HttpTriggerTest: [GET,POST] http://localhost:7071/api/HttpTriggerTest

[9/1/2019 4:52:07 PM] python: can't open file 'C:\Users\First': [Errno 2] No such file or directory
[9/1/2019 4:52:07 PM] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[9/1/2019 4:52:07 PM] Stopping host...
[9/1/2019 4:52:07 PM] Stopping JobHost
[9/1/2019 4:52:07 PM] Job host stopped
[9/1/2019 4:52:07 PM] Host shutdown completed.
Application is shutting down...

注意:错误消息指出文件C:\Users\First无法打开,因为它不存在。它确实不存在。存在的是一个名为“C:\Users\First Last”的文件夹。可能是我的windows用户名中的空格引起了问题?在


Tags: 函数nohostopenfunctionscanusersfile
2条回答

这是较早的python版本的问题。在

在执行以下操作时,请确保以管理员身份运行teminals或vscode
  1. 你在使用什么版本的python?在

    如果您使用的是小于3.6.8的内容,则必须卸载旧版本并从here下载最新版本

  2. 您使用的是azure-functions-core-tools的哪个版本?在

    即使在安装了最新版本的python之后,如果您的问题没有得到解决->;也可以尝试卸载此版本,然后reboot您的计算机->;然后执行npm install -g azure-functions-core-tools

  3. 即使这不起作用,暂时禁用Windows Defender实时扫描

实际上,这是因为您将目录放在单引号''中,所以需要将它们放在双引号""中。 i、 e."C:\Program Files\Python 3.4\python.exe"

如果这不是关键问题,请分享一些导致问题的代码。在

相关问题 更多 >