pythonandroidopenai-apichaquopywebvtt

Can I make use charset-normalizer 3.0.0 instead of 3.2.0 in build.gradle so that I do not get aiohttp related library error in android studio?


I am using chaquopy to integrate python into android. I am making a fairly simple app the uses the openai and webvtt libraries; hence my src/main/script.py contains "import open ai" and "import webvtt" at the beginning of the script. I also have in my build.gradle the block:

android {

    namespace 'com.example.python_integration'
    compileSdk 33

    defaultConfig {


        python{
            pip{
                install "numpy"
            }
        }
        python{
             pip{
                install "openai"
            }
        }
        python{
            pip{
                install "tk"
            }
        }
        python{
            pip{
                install "webvtt_py"
            }
        }

When I run the app in an emulator I get a warning "aiohttp 3.8.1 has requirement charset-normalizer<3.0,>=2.0, but you'll have charset-normalizer 3.2.0 which is incompatible."

I tried adding an implementation to the gradle:

implementation 'com.github.Ousret:charset_normalizer:3.0.0'

as well as trying

implementation 'com.github.mizosoft.charset-normalizer:charset-normalizer:3.0.0'

But I still get the error/warning. Is this warning significant? Is there another block of code I need to add so that the gradle uses the previous charset-normalizer version? The app still runs but I am still editing my script.py so I have no way of knowing whether this is a critical error or not at this stage, I am currently just making sure I can get all of the libraries I need to work from my original python script. Sometimes when I build the app in the emulator I don't even get this error in the build log so it is a little frustrating that it randomly keeps popping up. Maybe I am wildly misunderstanding the situation?


Solution

  • The warning may or may not be critical, depending on what your app does. But you can probably work around it by adding a direct requirement on the indicated version:

    install "charset-normalizer<3.0,>=2.0"
    

    The reason you don't see the warning every time you build your app is that it only re-runs pip when you change the pip block, or other relevant settings like the Python version.

    Additional notes: