chaquo pyException ModuleNotFoundError:没有名为“ quaternion”的模块

问题描述

我正在尝试将Gradle文件上的以下更改集成到我的android java项目中。 但是它会产生模块错误。但是我给pip安装列表提供了相同的模块。它安装成功,但仍然显示相同的错误。

请查看以下错误: java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.myapplication / com.example.myapplication.MainActivity}:com.chaquo.python.PyException:ModuleNotFoundError:没有名为“ quaternion”的模块

应用级gradle:

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

}
android {
    compileSdkVersion 29
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        python {
            buildPython "C:/Users/Bridge Global/AppData/Local/Programs/Python/Python38/python.exe"

            pip {
                // A pip requirement specifier,with or without a version number:

                install "scipy"
                install "numpy"
                install "quaternion"
                install "pandas"
                install "matplotlib"

            }


        }
        ndk {
            abiFilters "armeabi-v7a","x86","arm64-v8a","x86_64"
        }

            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.1.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

项目级别gradle:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url "https://chaquo.com/maven" }    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"
        classpath "com.chaquo.python:gradle:8.0.0"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

主要活动

if (! Python.isStarted()) {
   
    Python.start(new AndroidPlatform(this));
    Python py = Python.getInstance();
    PyObject pyObject =py.getModule("backend");
}

任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)