Home > database >  ModuleNotFoundError: No module named 'xgboost.sklearn' only on cloud. It works locally
ModuleNotFoundError: No module named 'xgboost.sklearn' only on cloud. It works locally

Time:01-18

i have a problem with module xgboost.sklearn.

I have a project developed with visual studio code ( azure extensions). I write in python. I need to import xgboost.sklearn so i add this to requirements.txt:

azure-functions
azure-cosmos

pybind11
scipy==1.5.4

pyyaml==6.0
numpy==1.19.5
pandas==1.1.5
scikit-learn==0.24.2
xgboost==0.80

I run it locally (F5 - start debugging). Everything works just fine. So i deployed functions and call my endpoint. I got 500: Result: Failure Exception: ModuleNotFoundError: No module named 'xgboost.sklearn' Stack:....... (line with import xgboost.sklearn)

I try pip freeze > requirements.txt - not working I have "azureFunctions.scmDoBuildDuringDeployment": true in settings.json My resources on Azure contains xgboost and sklearn (.python_packages/lib/site-packages): enter image description here

How can i fix it?

CodePudding user response:

Try using hit and trail on multiple versions of scikit-learn to install and see what works.

CodePudding user response:

After reproducing from my end, When I tried deploying with manually given requirements.txt I have received the similar issue. This is working fine after following the below steps.

Step1: Installed the scikit-learn and xgboost locally and then generated rerequirements.txt file using pip freeze > requirements.txt.

enter image description here

Step2: Now deployed the function to Function App

enter image description here

Then I have tested my function App which executed successfully.

enter image description here

  • Related