Hi,
Today I tried to run azure function in python.
I am working on Windows.
Created project using:
func init pythonProject --worker-runtime python
Created python function using:
func new --language python --template "HttpTrigger" --name myFunction
All this steps succeed:
Next tried to host them using:
func host start
And when all succeed got message:
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Http Functions:
myFunction: [GET,POST] http://localhost:7071/api/myFunction
[14.02.2019 19:37:26] Traceback (most recent call last):
[14.02.2019 19:37:26] Traceback (most recent call last):
[14.02.2019 19:37:26] File "C:\Users\xxxx\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\worker.py", line 37, in main
[14.02.2019 19:37:26] File "C:\Users\xxxx\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\worker.py", line 46, in <module>
[14.02.2019 19:37:26] return aio_compat.run(azure.functions_worker.start_async(
[14.02.2019 19:37:26] main()
[14.02.2019 19:37:26] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[14.02.2019 19:37:26] File "C:\Users\xxxx\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\worker.py", line 37, in main
[14.02.2019 19:37:26] return aio_compat.run(azure.functions_worker.start_async(
[14.02.2019 19:37:26] AttributeError: module 'azure.functions_worker' has no attribute 'start_async'
[14.02.2019 19:37:26] Language Worker Process exited.
[14.02.2019 19:37:26] python exited with code 1
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
Any thoughts?
Installing via chocolatey doesn't solve the issue. It was suggested somewhere.
In the end, it just uses azure-functions-core-tools just path will be different.
I installed latest version 2.4.317 but tried also [email protected].
The same result.
I also check that the same instructions work for dotent and node and they worked.
The bug appears only in python
can you share the output of
python --version
# and
pip freeze
from your venv.
/cc @maiqbal11
@ahmelsayed sure below you will find output:
(.environment) c:\Users\xxxx\Documents\pyfirst>python --version
Python 3.6.0
and second
(.environment) c:\Users\xxxx\Documents\pyfirst>pip freeze
azure-functions==1.0.0b3
azure-functions-worker==1.0.0b3
cycler==0.10.0
grpcio==1.14.2
grpcio-tools==1.14.2
kiwisolver==1.0.1
matplotlib==3.0.2
numpy==1.16.1
protobuf==3.6.1
pyparsing==2.3.1
python-dateutil==2.8.0
six==1.12.0
You are using pip version 9.0.1, however version 19.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
@wolszakp, do you happen to have an older version of azure-functions-worker installed globally (outside the venv)? You can check with pip freeze outside of venv. If so, would you mind updating and trying it again?
I think the error is because our worker is somehow accessing an older version of azure-functions-worker. This shouldn't ideally happen. If this solves it, I will investigate why our Python process is accessing modules globally.
@wolszakp, do you happen to have an older version of
azure-functions-workerinstalled globally (outside the venv)? You can check withpip freezeoutside of venv. If so, would you mind updating and trying it again?I've installed
azure-functions-core-toolsglobally
npm install -g azure-functions-core-tools
pip freeze outside of venv outputs me this
c:\Users\xxxx\Documents>pip freeze
astroid==2.1.0
colorama==0.4.1
cycler==0.10.0
isort==4.3.4
kiwisolver==1.0.1
lazy-object-proxy==1.3.1
matplotlib==3.0.2
mccabe==0.6.1
numpy==1.16.1
pylint==2.2.2
pyparsing==2.3.1
python-dateutil==2.8.0
six==1.12.0
typed-ast==1.3.1
wrapt==1.11.1
I assume that it looks good.
I think the error is because our worker is somehow accessing an older version of
azure-functions-worker. This shouldn't ideally happen. If this solves it, I will investigate why ourPythonprocess is accessing modules globally.
How can I check if I got an older version of azure-functions-worker?
@wolszakp, thanks for the outputs. That looks good to me!
How can I check if I got an older version of
azure-functions-worker?
If you had a version of azure-functions-worker globally it would have shown up in pip freeze. So, that part looks good.
I haven't been able to reproduce it on my machine. Would you mind trying another couple of things for me to help investigate?
Inside your virtualenv .environment that you activated, could you run python interpreter and try these lines and report the output-
import azure.functions_worker
from azure.functions_worker.main import main
azure.functions_worker.__version__
@ankitkumarr -thanks.
There is the error at the end:
ImportError: DLL load failed: The specified procedure could not be found.
This is the full output:
(.environment) c:\Users\xxxx\Documents\pyfirst>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import azure.functions_worker
>>> from azure.functions_worker.main import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\main.py", line 7, in <module>
from . import dispatcher
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\dispatcher.py", line 15, in <module>
from . import bindings
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\bindings\__init__.py", line 2, in <module>
from .meta import check_input_type_annotation
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\bindings\meta.py", line 8, in <module>
from .. import protos
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\protos\__init__.py", line 1, in <module>
from .FunctionRpc_pb2_grpc import ( # NoQA
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\protos\FunctionRpc_pb2_grpc.py", line 4, in <module>
from azure.functions_worker.protos import FunctionRpc_pb2 as azure_dot_functions__worker_dot_protos_dot_FunctionRpc__pb2
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\azure\functions_worker\protos\FunctionRpc_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\xxxx\Documents\pyfirst\.environment\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
and azure.functions_worker.__version__
>>> azure.functions_worker.__version__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'azure.functions_worker' has no attribute '__version__'
I am getting the same error
import azure.functions_worker
>>> from azure.functions_worker.main import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\main.py", line 7, in <module>
from . import dispatcher
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\dispatcher.py", line 15, in <module>
from . import bindings
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\bindings\__init__.py", line 2, in <module>
from .meta import check_input_type_annotation
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\bindings\meta.py", line 8, in <module>
from .. import protos
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\protos\__init__.py", line 1, in <module>
from .FunctionRpc_pb2_grpc import ( # NoQA
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\protos\FunctionRpc_pb2_grpc.py", line 4, in <module>
from azure.functions_worker.protos import FunctionRpc_pb2 as azure_dot_functions__worker_dot_protos_dot_FunctionRpc__pb2
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\azure\functions_worker\protos\FunctionRpc_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\JKrueger\az_func_cpgai\.env\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
Using windows 10 and using azure-functions-core-tools v2.4.317 installed via Chocolatey. I have installed azure-functions==1.0.0b3 globally, but it's the same version inside the virtualenv.
@wolszakp, @JK87iab thanks for that! That (from google.protobuf.pyext import _message) error seems to be the real problem.
Looks like this is a reported bug in Python 3.6.0 with protobuf 3.6.1.
From the issues, it seemed like several libraries had similar issues with that version of Python. If you guys wouldn't mind updating Python to (>=) 3.6.1, that should solve the problem. Let me know if that works out.
fyi, @maiqbal11 and @elprans (in case you guys see similar issues opened in the worker repository).
I ran a quick test with python 3.6.8 and it worked.
func host start
....
[2/25/2019 3:51:17 AM] INFO: Starting Azure Functions Python Worker.
[2/25/2019 3:51:17 AM] INFO: Worker ID: d643b069-c075-4ad4-979b-d5fd2e62394c, Request ID: 4c09f2bd-4aef-456d-8a25-82f8338c001f, Host Address: 127.0.0.1:61455
[2/25/2019 3:51:17 AM] INFO: Successfully opened gRPC channel to 127.0.0.1:61455
[2/25/2019 3:51:17 AM] INFO: Received WorkerInitRequest, request ID 4c09f2bd-4aef-456d-8a25-82f8338c001f
[2/25/2019 3:51:17 AM] Adding language worker channel for runtime: python.
[2/25/2019 3:51:17 AM] INFO: Received FunctionLoadRequest, request ID: 4c09f2bd-4aef-456d-8a25-82f8338c001f, function ID: 138ed700-ead1-421a-a510-d42b5e847787
[2/25/2019 3:51:17 AM] INFO: Successfully processed FunctionLoadRequest, request ID: 4c09f2bd-4aef-456d-8a25-82f8338c001f, function ID: 138ed700-ead1-421a-a510-d42b5e847787
[2/25/2019 3:51:21 AM] Host lock lease acquired by instance ID '00000000000000000000000063AE5328'.
Thanks @ankitkumarr
Upgrading python to 3.6.8 solve the issue.
c:\Users\xxx\Documents\pyfirst>python --version
Python 3.6.8
I'm running Python 3.6.8 on Windows 10 in virtual environment and still receiving the error when running "func host start":
AttributeError: module 'azure.functions_worker' has no attribute 'start_async'.
I am using Azure Functions Core Tools (2.7.1158 Commit hash: f2d2a2816e038165826c7409c6d10c0527e8955b)
Function Runtime Version: 2.0.12438.0
Here is my output from pip freeze:
azure-functions==1.0.0b4
azure-functions-worker==1.0.0b6
entrypoints==0.3
enum34==1.1.6
flake8==3.7.7
futures==3.1.1
grpcio==1.20.1
grpcio-tools==1.20.1
mccabe==0.6.1
protobuf==3.7.1
pycodestyle==2.5.0
pyflakes==2.1.1
six==1.12.0
I ran the following commands in Python without error:
import azure.functions_worker
from azure.functions_worker.main import main
I get an error with the third command:
azure.functions_worker.__version__
Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'azure.functions_worker' has no attribute '__version__'
I assume this is another version compatibility issue. Any thoughts? These are the latest versions of most tools, so wondering if I need an older version.
FYI, I discovered that my issue was having a 32-bit version of Python installed rather than the 64-bit. Once 32-bit uninstalled and 64-bit installed, I no longer received any errors.
I can second @shietpas, I got the error when using Python 3.6.8 (32-bit), but installing Python 3.6.8 (64-bit) solved the problem.
Glad you were able to discover the workarounds. Sorry I couldn't help.
It's usually good to open new issues when you face similar issues and link the related ones, as we don't track closed issues, and may miss notifications some times.
I think this issue is related to https://github.com/Azure/azure-functions-python-worker/issues/450. Because we built the binaries in a 64 bit machine, it fails on a different architecture. We will explore our options, but the workaround would be to use 64-bit Python.
FYI, I discovered that my issue was having a 32-bit version of Python installed rather than the 64-bit. Once 32-bit uninstalled and 64-bit installed, I no longer received any errors.
I know this is closed but going from 32 bit to 64 resolved my same issue. Thank you, @shietpas
I was having a similar issue: when running _func host start_ I was seeing error: azure has no attribute functions
The problem in my case was that I had named the function in my app directory http (instead of HttpTrigger), which led to a circular reference due to the builtin module http being a requirement. Dumb!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
FYI, I discovered that my issue was having a 32-bit version of Python installed rather than the 64-bit. Once 32-bit uninstalled and 64-bit installed, I no longer received any errors.