Azure web app AttributeError: module 'typing' has no attribute '_ClassVar'

GUENBOUR Mohamed 10 Reputation points
2023-02-09T19:50:30.75+00:00

Hi,

I try to deploy a streamlit application from github to azure app service. In github I have the folowing files:

  • requirements.txt
  • myapp.py
  • myfile.pkl

Python version : 3.8

On Github, build and deploy run successfully but when i click on the app Service Application URL, I have this error : AttributeError: module 'typing' has no attribute '_ClassVar'

I need help to solve this issue.

Thanks

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,936 questions
{count} vote

1 answer

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2023-02-14T12:14:30.0033333+00:00

    @GUENBOUR Mohamed ,

    Based on the info you have shared, it could indicate that, the 'typing' module in Python 3.8 has a different implementation of the '_ClassVar' attribute than in previous versions.

     

    Just to highlight, App Service uses the Gunicorn web server by default. The Apps are run using the Gunicorn WSGI HTTP Server.

     

    • If you haven’t done this already, review and update the Python version from the Azure portal.
      ( App Service WebApp> Configuration" tab > General settings, change the version of Python that is being used)
    • Review and update the dependencies in your requirements.txt file to ensure that they are compatible with the new version of Python.
    • You may try executing the command "pip install -r requirements.txt" separately in the App Service container to see if there are any errors or issues with the modules. Ensure that the requirements.txt file is in root directory.
    • I understand you have mentioned, you're leveraging Python 3.8, you may run the following command:
      pip install -r requirements.txt --upgrade

    After updating the version of Python and the dependencies, you will need to redeploy your WebApp to Azure App Service.
    ( Try by pushing the updated code to your GitHub repository and then triggering a new deployment in Azure)

     

    • If the issue still persist, review Access diagnostic logs and deployment logs to fetch more info ( as outlined in this doc)

    Additional info:

    Kindly let us know how it goes, I'll follow-up with you further.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.