cannot import 'run' (aio_compat.py) (only fails in my local environment using VSCode)
See original GitHub issueI have a very simple azure function that gets a parameter (please see the code at the bottom) and returns a HttpResponse, after running it it fails with:
cannot import name 'run'
File "c:\users\saul.cruz\appdata\roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\deps\azure\functions_worker\aio_compat.py", line 84, in <module>
from asyncio import run, get_running_loop # NoQA
File "c:\users\saul.cruz\appdata\roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\deps\azure\functions_worker\main.py", line 6, in <module>
from . import aio_compat
File "c:\users\saul.cruz\appdata\roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\worker.py", line 5, in <module>
from azure.functions_worker.main import main
This only happens locally, the deployed function is working appropriately in the azure function service
Investigative information
Please provide the following:
- Timestamp: 2019-07-08T19:05:00
- Function App name: HttpTriggerFTPCheck
- Function name(s) (as appropriate):
- Core Tools version: win-x64.2.7.1373
- Python version : Python 3.6.7 :: Anaconda, Inc.
Repro steps
Provide the steps required to reproduce the problem:
I only have a very simple function that gets a parameter and returns a JSON response with that parameter’s value…
- Debug
__init__.py
It’s been working for almost one week and suddenly the following error started happening: This only happens in my local environment (PC), not the actual azure function that is deployed already. Not sure about what is going on, I’ve seen this when there are circular dependencies, but I’m not sure about this case.
Expected behavior
Provide a description of the expected behavior.
Response with:
"result": "saul"
Actual behavior
Provide a description of the actual behavior observed.
It’s been working for almost one week and suddenly the following error started happening:
cannot import name 'run'
File "c:\users\saul.cruz\appdata\roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\deps\azure\functions_worker\aio_compat.py", line 84, in <module>
from asyncio import run, get_running_loop # NoQA
File "c:\users\saul.cruz\appdata\roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\deps\azure\functions_worker\main.py", line 6, in <module>
from . import aio_compat
File "c:\users\saul.cruz\appdata\roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\worker.py", line 5, in <module>
from azure.functions_worker.main import main
Known workarounds
Provide a description of any known workarounds.
Related information
Provide any related information
- Links to source
- Contents of the requirements.txt file
- Bindings used
#__init__.py
import logging
import json
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(json.dumps({'result': name}))
else:
return func.HttpResponse(
"Please pass a name on the query string or in the request body",
status_code=400
)
azure-functions==1.0.0a4
azure-functions-worker==1.0.0a4
grpcio==1.14.2
grpcio-tools==1.14.2
protobuf==3.6.1
six==1.11.0
functions.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:16 (2 by maintainers)
Top GitHub Comments
Thanks, @anirudhgarg ! Your tip saved my life here! Thank you!
This is an issue with the Python VSCode extension. Please find the workaround here till this is fixed: https://github.com/Azure/azure-functions-core-tools/issues/2026#issuecomment-642168916