0

I have a python function that I've created as an Azure App Function. It works on my local machine fine, however fails with no descriptive error when executed after a successful publishing.

Originally, it failed with 500 internal server error due to:

Result: Failure
Exception: ModuleNotFoundError: No module named 'pandas'
Stack:   File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/azure/functions_worker/dispatcher.py", line 218, in _handle__function_load_request
    func_request.metadata.entry_point)
  File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/azure/functions_worker/loader.py", line 66, in load_function
    mod = importlib.import_module(fullmodname)
  File "/root/.pyenv/versions/3.6.8/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/site/wwwroot/generateGraph/__init__.py", line 2, in <module>
    import pandas as pd

I thought this was me not publishing with the --build-native-deps switch. So I republished with this switch: (.env) C:\Temp\python_function>func azure functionapp publish httpGenGraph --build-native-deps

And publishing was successful. Now, when I execute the Http Trigger, I get the same error again. Is there something I'm missing? I'm new to Python so it could be not understanding the packaging requirements or something. The function does work within my local virtual python environment.

2
  • Have you tried to install the module 'pandas' via kudu? Commented Apr 11, 2019 at 5:35
  • Figured it out (see my answer below). Now working as expected :) No doubt a stupid python beginner mistake on my part! Commented Apr 11, 2019 at 5:47

1 Answer 1

1

Figured it out. I needed to pipe the output of pip freeze to the requirements.txt file. This allowed the packages to be properly referenced when publishing.

For reference:

(.env) C:\Temp\python_function>pip freeze > requirements.txt

Then:

(.env) C:\Temp\python_function>func azure functionapp publish httpGenGraph --build-native-deps
Sign up to request clarification or add additional context in comments.

1 Comment

Please accept this as a answer so that it will help community.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.