question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError for pandas when hosted in Azure

See original GitHub issue

Python function, works fine locally using either VS Code and command line. Deployed using VS Code. Expected to work fine in Azure. However, In Azure I get a 500 response. Error code is ‘ModuleNotFoundError’. Same result on both Consumption and Dedicated plans. Full error message below:

Result: Failure Exception: ModuleNotFoundError: No module named 'pandas' Stack: File "/usr/local/lib/python3.6/site-packages/azure/functions_worker/dispatcher.py", line 230, in _handle__function_load_request func_request.metadata.entry_point) File "/usr/local/lib/python3.6/site-packages/azure/functions_worker/loader.py", line 66, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/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/Predict/__init__.py", line 6, in <module> from .SharedCode.predict import predict File "/home/site/wwwroot/Predict/SharedCode/predict.py", line 4, in <module> import pandas as pd

There are other modules in the same file which don’t throw this error. See head of predict.py:

import logging
import pickle
from . import (utils, data)
import pandas as pd

class predict():
...

My requirements.txt file:

astroid==2.2.5
azure-functions==1.0.0b4
colorama==0.4.1
isort==4.3.20
joblib==0.13.2
lazy-object-proxy==1.4.1
mccabe==0.6.1
numpy==1.16.3
pandas==0.24.2
pylint==2.3.1
python-dateutil==2.8.0
pytz==2019.1
scikit-learn==0.21.1
scipy==1.3.0
six==1.12.0
typed-ast==1.3.5
wrapt==1.11.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Hazhzengcommented, Oct 14, 2019

@LbrsRyanS Please follow the vscode-azurefunctions wiki page for deploying with remote build https://github.com/microsoft/vscode-azurefunctions/wiki/Remote-Build

@AbdolrezaMadi When using the remote build, your package should be resolved on our servers instead of your local machine. Your functions core tools is out of date (2.4.419) and it does not support remote build. You may want to update it by npm i -g azure-functions-core-tools --unsafe-perm true and the build --remote flag should work after downloading the latest core tools.

1reaction
AbdolrezaMadicommented, Oct 14, 2019

Thanks a lot for the tip. It solved the problem I mentioned. After fixing this issue, I got another problem with azure-function package, which is explained here: https://github.com/Azure/azure-functions-python-worker/issues/504 Upgrdaing this package to version 1.0.4 and removing azure-functions-worker from my requirements.txt fixed the issues (I recreated the function app, since it was recommended in the Remote-Build procedure).

Thanks again

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas import causing problems with Azure Function
I am trying to put together an Azure function to run on an HTTP trigger. My problem is whenever I run the function...
Read more >
No module named 'pandas' in application service azure with ...
If you see an error like ModuleNotFoundError: No module named 'example' , this means that Python could not find one or more of...
Read more >
[Fixed] ModuleNotFoundError: No module named 'azure ...
Quick Fix: Python raises the ImportError: No module named 'azure-common' when it cannot find the library azure-common . The most frequent source of...
Read more >
pandas module not found vscode - You.com | The AI Search ...
VS Code: ModuleNotFoundError: No module named 'pandas' ... 1. If you have multiple versions of python installed and/or have something like acaconda installed,...
Read more >
How to Fix: No module named pandas - GeeksforGeeks
The error “No module named pandas ” will occur when there is no pandas library in your environment IE the pandas module is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found