pygobject/pycairo

NEED Clarification and Help

AvinandanPal25 opened this issue · 11 comments

Hello all,

I am working on a python project to analyze WhatsApp chat.
So when I tried to deploy it, I came across this quite bothering term "pycairo".
It made my life difficult for the last couple of days. NEED HELP !!


  • I, first of all, can not understand why this DEPENDENCY was listed when I ran the "requirements file". I am using word cloud, PIL, and Emoji packages in the project. Does any of these have anything to do with it?

  • When I was trying to deploy the project, the error I got was:
    'pkg-config' not found. Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']

  • Then, I looked at some of the solutions specified here.
    I downloaded and tried to include cp27, cp37, cp39 versions of pycairo wheels
    to which the deploying platform (I am using Streamlit community) threw this error:
    pycairo-1.21.0-cp37-cp37m-win32.whl is not a supported wheel on this platform.

WHAT IS THE SOLUTION TO THIS ISSUE?
Kindly guide. I am on Windows, so it will be more beneficial for me if you answer in that PROSPECTIVE.

In advance, many thanks for considering my request. I really need the solution at the earliest.

Hi @AvinandanPal25
What version of python are you using ?
Can when you try and install PyCairo from pip and paste the output here ?

Cheers

Hi @stuaxo, thanks for reaching out to help.

I am using python 3.9.5.
And I had already installed PyCairo, both by using the pip command, and later on by downloading the actual wheel file and then installing it.

Here's a snap of it.
Screenshot 2022-12-02 163130

The warning here might have something to do with my virtual env.

I found this info about your warning
https://www.pythonpool.com/solving-python-ignoring-invalid-distribution/#:~:text=Warning%3A%20Ignoring%20invalid%20distribution%20This%20happens%20because%20when,own%20package%20%28pip%20-%3E%20~ip%29%20without%20restoring%20it.

It looks like pycairo is installed (of course this doesn't mean it's working).

How exactly are you triggering the error you are getting, and what is the it ?

I don't think there's enough information here to reproduce it yet.

The warning (in brown color text) in the above photo is not the actual problem. I mentioned it there itself. pycairo is installed.

The error at first was 'pkg-config' not found. Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10'] and
later, after I installed pycairo, the error was pycairo-1.21.0-cp37-cp37m-win32.whl is not a supported wheel on this platform. while I was deploying the app over Streamlit

I'm not familiar with Streamlit, so would need more information on how to reproduce this issue, since it's sounds like something different to standard python.

Sure @stuaxo
Streamlit Community is a platform to deploy Streamlit Dashboards. Find Here

And streamlit in itself is an Open Source framework in Python, somewhat similar to Flask. It has its own functions to create the app and add functionality. So we just need to install and import, and we are good to go.
It has built-in functions for making buttons, text areas, number inputs, select-box, and sliders. Documentation
It's a Quicker Fix. Also, we need not to know HTML/CSS/JS to build dashboards.

I do hope that this will be sufficient.

Hi @stuaxo and @AvinandanPal25 it seems I have the same issue here.
https://discuss.streamlit.io/t/problem-deploying-with-pycairo/42285
Did you find any solution for the problem?

Sorry, I'm not familiar with streamlit, what platform it's on or if it's a platform itself.

The errors here mention a python whl for the windows platform but that thread mentions apt-get which would usually be a debian based Linux, so I don't think I have enough information to help.

Streamlit is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science. In just a few minutes you can build and deploy powerful data apps.

And this is the GitHub action used to deploy the Streamlit app to the Azure static web app, which fails on creating the wheels, the environment used is Ubuntu as you can see in the action.

Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy

name: Build and deploy Python app to Azure Web App - mep-configurator

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python version
        uses: actions/setup-python@v1
        with:
          python-version: '3.10'

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
      
      - name: Install dependencies
        run: |
          sudo apt-get install libcairo2-dev pkg-config python3-dev
          sudo apt install libgirepository1.0-dev
          pip install -r requirements.txt
        
      # Optional: Add step to run tests here (PyTest, Django test suites, etc.)
      
      - name: Upload artifact for deployment jobs
        uses: actions/upload-artifact@v2
        with:
          name: python-app
          path: |
            . 
            !venv/

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: python-app
          path: .
          
      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        id: deploy-to-webapp
        with:
          app-name: 'mep-configurator'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D66086F2554D4C2F9BE23A1323FCFE87 }}

Cheers, that makes things clearer I didn't know Azure webapp is a thing.

This is different issue to the one @AvinandanPal25 is having as I can see Azure webapp is running Ubuntu and the original error is for windows so I'll move your query to its own ticket.

I'm going to close this for now, can reopen if @AvinandanPal25 comes back with more info, but the issue there is trying to use the whl for the wrong OS.

I've started another ticket for the error @sonomirco is getting from pycairo, trying to use streamlit on Azure webapp.