question

NikhilN-0814 avatar image
0 Votes"
NikhilN-0814 asked ajkuma-MSFT answered

Import Error during Dajngo app deployment

I am trying to deploy my Django app on azure. While pushing my Django project to Azure git, "tflite-runtime" was not getting installed in the remote. hence I removed it from the requirement.txt and pushed it to master.
later in azureapp.xxx.x.x.x.x.webssh/host, I tried to install "tflite-runtime" using "pip3 install --extra-index-url https://google-coral.github.io/py-repo/ tflite_runtime", as well as other libraries from my requirement list and, was successful. Later when I run python mange.py migrate I get the below error.


File "/home/site/wwwroot/myapp/urls.py", line 4, in <module>
from . import views
File "/home/site/wwwroot/myapp/views.py", line 19, in <module>
import tflite_runtime.interpreter as tflite
File "/opt/python/3.8.6/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 36, in <module>
from tflite_runtime import _pywrap_tensorflow_interpreter_wrapper as _interpreter_wrapper
ImportError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /opt/python/3.8.6/lib/python3.8/site-packages/tflite_runtime/_pywrap_tensorflow_interpreter_wrapper.cpytho
n-38-x86_64-linux-gnu.so)

Can some please help as i am really new to all this?




azure-webapps
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NikhilN-0814,

Apologies for the delay! You could add a startup command to run the script to install the packages or you could build this on your custom image and deploy it via Web App for containers.

The App Service deployment engine automatically activates a virtual environment and runs pip install -r requirements.txt for you when you deploy a Git repository.
Kindly ensure you’re using relative paths in all pre- and post-build scripts because the build container in which Oryx runs is different from the runtime container in which the app runs.

Virtual environments are not portable, so a virtual environment should not be deployed with your application code.

Also, you could let Oryx create a virtual environment and install your packages on the web app by creating an app setting, SCM_DO_BUILD_DURING_DEPLOYMENT, and setting it to 1. This will force Oryx to install your packages whenever you deploy to App Service.

0 Votes 0 ·
ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered

@NikhilN-0814, Adding more info:

For Django apps, App Service looks for a file named wsgi.py within your app code, and then runs Gunicorn.

So, you may use a custom startup command, replace <module> with the name of folder that contains wsgi.py, and add a --chdir argument if that module is not in the project root.

Your requirements.txt file must be at the root of your repository for App Service to automatically install the necessary packages.

As a side note, the startup script and modify all these paths relative to $APP_PATH.

I would suggest you to try the steps outlined in this doc for customization:
Configure a Linux Python app for Azure App Service - https://docs.microsoft.com/azure/app-service/configure-language-python#customize-build-automation

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered

To narrow-down/fetch more details on the error:

Leverage App Service diagnostics from Azure Portal> navigate to your App Service app in the Azure portal -to fetch more details on the error.
In the left navigation, click on Diagnose and solve problems – Checkout the tile for “Diagnostic Tools” > “Availability and Performance” & "Best Practices".

Access Kudu - https://<Your app name>.scm.azurewebsites.net/ - to analyze logs and collect diagnostic dumps as required.

80303-image.png




image.png (79.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.