Forum Discussion
WernerKoen
Mar 11, 2025Copper Contributor
Unable to get Python3.12 running on Azure App services
Good day, I am having endless trouble getting a python app to run on azure service apps. I cannot find anywhere to install modules like pip, which I need to install openai. Can someone please assis...
Kidd_Ip
Mar 13, 2025MVP
Take this:
- Ensure a requirements.txt File:
- Azure App Services automatically installs Python dependencies listed in a requirements.txt file during deployment. Make sure this file is in the root directory of your project and includes all the required modules (e.g., openai).
- Check Python Version:
- Azure App Services supports specific Python versions. Verify that Python 3.12 is supported or consider using a supported version. You can check and set the Python version using the Azure CLI:
az webapp config set --resource-group <resource-group-name> --name <app-name> --linux-fx-version "PYTHON|3.12"
- Enable Build Automation:
- Ensure the SCM_DO_BUILD_DURING_DEPLOYMENT setting is enabled. This triggers the build process, including the installation of pip modules. You can enable it in the Azure portal under "Configuration" or via the Azure CLI:
az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
- Use a Virtual Environment:
- If you're deploying manually, activate a virtual environment locally, install the required modules, and then deploy the app along with the virtual environment.
- Check Deployment Logs:
- Review the deployment logs in the Azure portal to identify any specific errors during the pip installation process.
- Consider a Custom Docker Image:
- If Python 3.12 isn't natively supported, you can create a custom Docker image with Python 3.12 and all the required modules pre-installed. Deploy this image to Azure App Services.