Skip to content
Advertisement

Failed to install cryptography in Android Studio using Chaquopy

I want to use camelot-py in Android Studio using Chaquopy.
But during installation of camelot-py, Gradle is unable to install cryptography

Chaquopy version : 12.0.1
Android Gradle Plugin Version : 7.2.2
minSDK : 21

build.gradle (top-level):

plugins {
    id 'com.android.application' version '7.2.2' apply false
    id 'com.android.library' version '7.2.2' apply false
    id 'com.chaquo.python' version '12.0.1' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (module-level):

plugins {
    id 'com.android.application'
    id 'com.chaquo.python'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "in.divyansh.extractdatafrompdftable"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }

        python {
            buildPython "C:/Users/LENOVO/AppData/Local/Programs/Python/Python310/python.exe"

            pip {
                install "camelot-py"
            }
        }

        sourceSets {
            main {
                python.srcDir "src/main/python"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.5.0'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

settings.gradle:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
        jcenter()
        maven { url "https://chaquo.com/maven"}
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "Extract Data from PDF Table"
include ':app'

Build Output:

> Task :app:generateDebugPythonRequirements
Chaquopy: Installing for armeabi-v7a
Looking in indexes: https://pypi.org/simple, https://chaquo.com/pypi-7.0
Collecting camelot-py
  Using cached https://files.pythonhosted.org/packages/3a/d3/08ae34725925bdaf85be36be7a230ba3ed7d6ae8e49a2276f1753620f347/camelot_py-0.10.1-py3-none-any.whl
Collecting tabulate>=0.8.9 (from camelot-py)
  Using cached https://files.pythonhosted.org/packages/92/4e/e5a13fdb3e6f81ce11893523ff289870c87c8f1f289a7369fb0e9840c3bb/tabulate-0.8.10-py3-none-any.whl
Collecting pdfminer.six>=20200726 (from camelot-py)
  Using cached https://files.pythonhosted.org/packages/92/1c/f0e976509c8d453cb0f1b360619bbc2b588ef733c32780c9e0221918b7fa/pdfminer.six-20220524-py3-none-any.whl
Collecting PyPDF2>=1.26.0 (from camelot-py)
  Using cached https://files.pythonhosted.org/packages/41/e4/0832d46a130c2e94110ef9b973ae22dd2879b9bae0c5e714875656a45c7e/PyPDF2-2.10.3-py3-none-any.whl
Collecting openpyxl>=2.5.8 (from camelot-py)
  Using cached https://files.pythonhosted.org/packages/7b/60/9afac4fd6feee0ac09339de4101ee452ea643d26e9ce44c7708a0023f503/openpyxl-3.0.10-py2.py3-none-any.whl
Collecting pandas>=0.23.4 (from camelot-py)
  Using version 1.3.2 (newest version is 1.4.3, but Chaquopy prefers native wheels)
  Using cached https://chaquo.com/pypi-7.0/pandas/pandas-1.3.2-0-cp38-cp38-android_16_armeabi_v7a.whl
Collecting numpy>=1.13.3 (from camelot-py)
  Using version 1.19.5 (newest version is 1.23.2, but Chaquopy prefers native wheels)
  Using cached https://chaquo.com/pypi-7.0/numpy/numpy-1.19.5-0-cp38-cp38-android_16_armeabi_v7a.whl
Collecting chardet>=3.0.4 (from camelot-py)
  Using cached https://files.pythonhosted.org/packages/4c/d1/1b96dd69fa42f20b70701b5cd42a75dd5f0c7a24dc0abfef35cc146210dc/chardet-5.0.0-py3-none-any.whl
Collecting click>=6.7 (from camelot-py)
  Using cached https://files.pythonhosted.org/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl
Collecting charset-normalizer>=2.0.0 (from pdfminer.six>=20200726->camelot-py)
  Using cached https://files.pythonhosted.org/packages/db/51/a507c856293ab05cdc1db77ff4bc1268ddd39f29e7dc4919aa497f0adbec/charset_normalizer-2.1.1-py3-none-any.whl
Collecting cryptography>=36.0.0 (from pdfminer.six>=20200726->camelot-py)
  Using cached https://files.pythonhosted.org/packages/89/d9/5fcd312d5cce0b4d7ee8b551a0ea99e4ea9db0fdbf6dd455a19042e3370b/cryptography-37.0.4.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'C:UsersLENOVOAppDataLocalProgramsPythonPython310python.exe' -S -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\LENOVO\AppData\Local\Temp\pip-install-y4i5i541\cryptography\setup.py'"'"'; __file__='"'"'C:\Users\LENOVO\AppData\Local\Temp\pip-install-y4i5i541\cryptography\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base pip-egg-info
         cwd: C:UsersLENOVOAppDataLocalTemppip-install-y4i5i541cryptography
    ERROR: Command errored out with exit status 1:

    Complete output (14 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:UsersLENOVOAppDataLocalTemppip-install-y4i5i541cryptographysetup.py", line 14, in <module>
        from setuptools_rust import RustExtension
    ModuleNotFoundError: No module named 'setuptools_rust'
    
            =============================DEBUG ASSISTANCE==========================
            If you are seeing an error here please try the following to
            successfully install cryptography:
    
            Upgrade to the latest pip and try again. This will fix errors for most
            users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
            =============================DEBUG ASSISTANCE==========================
    
    ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

ERROR: Failed to install cryptography>=36.0.0 from https://files.pythonhosted.org/packages/89/d9/5fcd312d5cce0b4d7ee8b551a0ea99e4ea9db0fdbf6dd455a19042e3370b/cryptography-37.0.4.tar.gz (from pdfminer.six>=20200726->camelot-py).
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
Or try using one of the following versions, which are available as pre-built wheels: ['2.8', '3.3.2', '3.4.8'].
Chaquopy: Exit status 1

Failed to install cryptography>=36.0.0 from https://files.pythonhosted.org/packages/89/d9/5fcd312d5cce0b4d7ee8b551a0ea99e4ea9db0fdbf6dd455a19042e3370b/cryptography-37.0.4.tar.gz (from pdfminer.six>=20200726->camelot-py).

> Task :app:generateDebugPythonRequirements FAILED
Execution failed for task ':app:generateDebugPythonRequirements'.
> Process 'command 'C:/Users/LENOVO/AppData/Local/Programs/Python/Python310/python.exe'' finished with non-zero exit value 1

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateDebugPythonRequirements'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Caused by: com.chaquo.python.BuildPythonFailedException: Process 'command 'C:/Users/LENOVO/AppData/Local/Programs/Python/Python310/python.exe'' finished with non-zero exit value 1

If anyone has any solution for this, plz help…

Advertisement

Answer

Chaquopy doesn’t currently provide such a new version of cryptography, but you can work around this by requesting a slightly older version of pdfminer.six:

        pip {
            install "camelot-py"
            install "pdfminer.six==20220319"
        }

This version of pdfminer.six doesn’t declare any minimum version of cryptography, so the install will complete successfully. However it probably still has an minimum requirement even if it’s not declared, so if you get any runtime errors suggesting an incompatibility between the two packages, try reducing the pdfminer.six version even further, if necessary all the way back to camelot-py‘s minimum requirement of 20200726.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement