I had an Azure function that worked completely fine, then I added the pytz package to my script.
In Azure I am getting the error:
ModuleNotFoundError: No module named ‘pytz’.
My requirements.txt file looks like this:
azure-functions
pyodbc==4.0.32
requests==2.28.0
pytz==2022.1
and the top of my actual script looks like this:
import datetime
import logging
import requests
import json
import pyodbc
import azure.functions as func
from datetime import datetime
from pytz import timezone
When I deploy the function from Python, I can see the packages getting installed in the output EXCEPT for pytz. Is it because in my script it is written as ‘from pytz’? I am very new to Python and appreciate any help.
2
Answers
Microsoft has given a solution and troubleshooting steps for this kind of error with detailed explanation that:
To mitigate this error, there are 2 solutions given by Microsoft which are replace the equivalent package or Handcraft requirements.txt file.
Check this document given by Microsoft.
After reproducing from my end, In my case the problem was with the python environment. Though the python environment is present make sure you activate the environment.
After activating i.e.,
<Your_Environment_Name>ScriptsActivate.ps1