Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'backports' #1732

Closed
Siam-Rayhan1 opened this issue Nov 2, 2023 · 1 comment
Closed

ModuleNotFoundError: No module named 'backports' #1732

Siam-Rayhan1 opened this issue Nov 2, 2023 · 1 comment
Labels

Comments

@Siam-Rayhan1
Copy link

Basically I'm making an app using Pythons kivy and kivymd frame work.In my app I'm using instaloader module.Using Github Action (CI) I'm converting my app to apk.
After converting,when i try to open my apk it crashes immediately.

Here's my Debug Log

I/python ( 8065): Traceback (most recent call last): 
I/python ( 8065): File "/github/workspace/.buildozer/android/app/main.py", line 9, in <module> 
I/python ( 8065): File "/github/workspace/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/stalkgram/arm64-v8a/instaloader/__init__.py", line 16, in <module> 
I/python ( 8065): File "/github/workspace/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/stalkgram/arm64-v8a/instaloader/instaloader.py", line 24, in <module> 
I/python ( 8065): File "/github/workspace/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/stalkgram/arm64-v8a/instaloader/nodeiterator.py", line 7, in <module> 
I/python ( 8065): File "<frozen zipimport>", line 259, in load_module 
I/python ( 8065): File "/github/workspace/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib/lzma.py", line 27, in <module> 
I/python ( 8065): ModuleNotFoundError: No module named '_lzma' 
I/python ( 8065): Python for android ended.

Here's my build.yml (CI)

name: CI
on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Get Date
        id: get-date
        run: |
          echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
        shell: bash

      - name: Cache Buildozer global directory
        uses: actions/cache@v2
        with:
          path: .buildozer_global
          key: buildozer-global-${{ hashFiles('buildozer.spec') }}

      - uses: actions/cache@v2
        with:
          path: .buildozer
          key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('buildozer.spec') }}
      - name: Install AIDL
        run: |
          sudo apt-get update
          sudo apt-get install build-essential
          sudo apt-get install libstdc++6
          sudo apt-get install aidl    
          sudo apt-get install -y liblzma-dev
          pip3 install backports.lzma
          pip3 install backports.weakref       
          
      - name: Build with Buildozer        
        uses: ArtemSBulgakov/buildozer-action@v1
        id: buildozer
        with:
          command: buildozer android debug
          buildozer_version: master

      - name: Modify lzma.py
        run: |
          cd .buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib

          sudo apt-get install -y liblzma-dev
          pip3 install backports.lzma
          pip3 install backports.weakref
          cd /home/runner/work/Stalkgram/Stalkgram
          ls
          sudo cp lzma.py .buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/other_builds/python3/arm64-v8a__ndk_target_21/python3/Lib
          
      - name: Upload artifacts
        uses: actions/upload-artifact@v2
        with:
          name: package
          path: ${{ steps.buildozer.outputs.filename }}

Here's my buildozer.spec requirements.

requirements = python3==3.9.10,hostpython3==3.9.10,kivy==2.1.0,pillow,kivymd==1.1.1,certifi,android,instaloader==4.10.1,plyer==2.1.0

Then i solved this issue following this

Before modification 
from _lzma import * 
from _lzma import _encode_filter_properties, _decode_filter_properties 
After modification 
try: 
 from _lzma import * 
 from _lzma import _encode_filter_properties, _decode_filter_properties 
except ImportError: 
 from backports.lzma import * 
 from backports.lzma import _encode_filter_properties, _decode_filter_properties

And it works.But now getting another error and that is

I/python  ( 7917):    File "/github/workspace/.buildozer/android/app/lzma.py", line 31, in <module>
I/python  ( 7917):  ModuleNotFoundError: No module named 'backports'
I/python  ( 7917): Python for android ended.
Copy link

github-actions bot commented Nov 2, 2023

👋 @Siam-Rayhan1,
Sorry to hear you are having difficulties with Kivy's Buildozer; Kivy unites a number of different technologies, so building apps can be temperamental.
We try to use GitHub issues only to track work for developers to do to fix bugs and add new features to Buildozer. This issue has been closed, because it doesn't describe a bug or new feature request for Buildozer.
There is a mailing list and a Discord channel to support Kivy users debugging their own systems, which should be able to help. They are linked in the ReadMe.
Of course, if it turns out you have stumbled over a bug in Buildozer, we do want to hear about it here. The support channels should be able to help you craft an appropriate bug report.

@github-actions github-actions bot closed this as completed Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants