chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
748 stars 127 forks source link

Can't install numpy >= 1.20 on Python 3.8 #1133

Closed nathaniacalista01 closed 2 months ago

nathaniacalista01 commented 2 months ago

Chaquopy version

Relevant parts of your build.gradle file

plugins {
    id("com.android.application")
    kotlin("android")
    id("androidx.navigation.safeargs.kotlin")
    id("com.chaquo.python")
}

android {
    namespace = "com.example.sioptik"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.sioptik"
        minSdk = 29
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
        ndk {
            abiFilters += listOf("arm64-v8a", "x86_64", "x86", "armeabi-v7a")
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        compose = true
        viewBinding = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.1"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

chaquopy{
    defaultConfig{
        buildPython("Path/Programs/Python/Python311/python.exe")
        pip{
            install("numpy==1.23.3")
//            install("opencv-python")
//            install("pupil_apriltags")
        }
    }
    sourceSets{
        getByName("main"){
            srcDir("src/main/python")
        }
    }

}

Describe your issue

I try to pip install a version of numpy, but I get this warning and error WARN: Could not locate executable g77 WARN: Could not locate executable f77 WARN: Could not locate executable ifort WARN: Could not locate executable ifl WARN: Could not locate executable f90 WARN: Could not locate executable DF WARN: Could not locate executable efl WARN: Could not locate executable gfortran WARN: Could not locate executable f95 WARN: Could not locate executable g95 WARN: Could not locate executable efort WARN: Could not locate executable efc WARN: Could not locate executable flang WARN: don't know how to compile Fortran code on platform 'nt' error: CCompiler.compile: Chaquopy cannot compile native code

mhsmith commented 2 months ago

The current version of Chaquopy defaults to Python 3.8, but we don't have NumPy 1.23.3 for that version of Python.

nathaniacalista01 commented 2 months ago

The current version of Chaquopy defaults to Python 3.8, but we don't have NumPy 1.23.3 for that version of Python.

May I know which version of NumPy supported by Chaquopy? I saw this version the link that you have referred, so I think this NumPy 1.23.3 is supported.

Update : I've tried to change my Python to 3.8 and install NumPy 1.20.3, but I still get an error

image

mhsmith commented 2 months ago

The "cp" part of the filename identifies the Python version. So the packages in that image are for Python 3.9.

nathaniacalista01 commented 2 months ago

I've tried to downgrade my Python version and install the compatible version of numpy, but it still get an error

mhsmith commented 2 months ago

As you can see from the repository, NumPy 1.20.3 is available for Python 3.9, and NumPy 1.23.3 for Python 3.9-3.11.

If you still can't install it, please post thechaquopy section of your build.gradle file, and the full build log.

nathaniacalista01 commented 2 months ago

Yup I still get an error and for more context, I need to use numpy that is >= 1.20, therefore I use a higher version of Python (not 3.8). This is my chaquopy section

chaquopy {
    defaultConfig {
        version = "3.11"
        buildPython("C:/Users/ASUS/AppData/Local/Programs/Python/Python311/python.exe")
        pip{
            install("numpy==1.23.3")
            install("opencv-python")
            install("pupil_apriltags")
        }
    }
}

And now I don't get any error, but it is still loading until now (already 30 minutes) image

mhsmith commented 2 months ago

Unfortunately we don't have OpenCV for Python 3.9 or later yet (#779). However, we do have a newer NumPy version for Python 3.8 in a separate repository: see https://github.com/chaquo/chaquopy/issues/559#issuecomment-989318791.

nathaniacalista01 commented 2 months ago

Thanks! it works like a charm for me