我正在尝试按照这里的MSDN指令执行一些python azure函数的本地测试:https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python
我已经安装了所有必要的依赖项,包括Python 3.6、Azure Functions Core Tools、Azure CLI &我有一个活动的Azure订阅。我还在powershell管理员模式下通过az login登录了我的Azure帐户。
一旦我完成了MSDN doc & run func host start powershell中提示的步骤,就会输出以下代码片段。我发现的一个错误是核心工具。我研究过这个错误,并看到其他人通过巧克力卸载并重新安装azure- AttributeError: module 'azure.functions_worker' has no attribute 'start_async'. - Azure Python App Function no longer runs locally - module 'azure.functions_worker' has no attribute 'start_async'成功地解决了这个问题。
问题仍然存在&我无法在本地托管azure函数&在浏览器(http://localhost:7071/api/HttpTrigger)中测试GET/POST请求。如果您熟悉如何解决此问题,请帮助我。我认为这可能是我的Python版本的问题,但我通过在powershell中运行python --version确认安装了Python3.6.0
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Http Functions:
HttpTrigger: [GET,POST] http://localhost:7071/api/HttpTrigger
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 46, in <module>
[6/26/2019 1:24:31 AM] main()
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Language Worker Process exited.
[6/26/2019 1:24:31 AM] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
[6/26/2019 1:24:31 AM] Starting language worker process:python "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py" --host 127.0.0.1 --port 64242 --workerId afead7f3-0f5e-4209-91f5-7904d3319d56 --requestId 9a2be9af-32d1-4199-9aaa-0d4aef01eef2 --grpcMaxMessageLength 134217728
[6/26/2019 1:24:31 AM] python process with Id=2360 started
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Traceback (most recent call last):
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 46, in <module>
[6/26/2019 1:24:31 AM] main()
[6/26/2019 1:24:31 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:31 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:31 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:31 AM] Language Worker Process exited.
[6/26/2019 1:24:31 AM] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
[6/26/2019 1:24:31 AM] Starting language worker process:python "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py" --host 127.0.0.1 --port 64242 --workerId 899213f3-400d-4355-a0cb-a42e425ef551 --requestId 2e8c49ea-6b15-444a-9e97-a07eefe09808 --grpcMaxMessageLength 134217728
[6/26/2019 1:24:31 AM] python process with Id=10060 started
[6/26/2019 1:24:32 AM] Traceback (most recent call last):
[6/26/2019 1:24:32 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:32 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:32 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:32 AM] Traceback (most recent call last):
[6/26/2019 1:24:32 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 46, in <module>
[6/26/2019 1:24:32 AM] main()
[6/26/2019 1:24:32 AM] File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\workers\python\worker.py", line 37, in main
[6/26/2019 1:24:32 AM] return aio_compat.run(azure.functions_worker.start_async(
[6/26/2019 1:24:32 AM] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[6/26/2019 1:24:32 AM] Language Worker Process exited.
[6/26/2019 1:24:32 AM] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
[6/26/2019 1:24:32 AM] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[6/26/2019 1:24:32 AM] Shuttingdown Rpc Channels Manager
[6/26/2019 1:24:32 AM] Stopping host...
[6/26/2019 1:24:32 AM] Stopping JobHost
[6/26/2019 1:24:32 AM] Job host stopped
[6/26/2019 1:24:32 AM] Host shutdown completed.
Application is shutting down...发布于 2019-06-27 04:04:56
我卸载了Python 3.6.0,然后在一个虚拟环境中安装了python 3.6.8。然后卸载并重新安装azure-functions-core-tools在同一个虚拟环境中,解决了这个问题。卸载&在CMD中通过巧克力完成安装。我还暂时禁用了Windows Defender实时扫描。
https://stackoverflow.com/questions/56763964
复制相似问题