1

这个 Gradle: 应用文件代码:

apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'
android {
compileSdkVersion 29
buildToolsVersion "30.0.1"

defaultConfig {
    applicationId "com.example.speechtotext"
    sourceSets{
        main{
            python{
                srcDirs=["src/main/python"]
            }
        }
    }

    minSdkVersion 16
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    python{

        buildPython "C:/Users/YASHWANTH REDDY/AppData/Local/Programs/Python/Python37/python.exe"}
    }
    python{
        pip{
            install "nltk"
        }
    }
    }
    buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
   }
   }
   }
   dependencies {
   implementation fileTree(dir: "libs", include: ["*.jar"])
   implementation 'androidx.appcompat:appcompat:1.2.0'
   implementation 'com.google.android.material:material:1.0.0'
   implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
   implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
   compile files('libs/opennlp-tools-1.6.0.jar')
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'androidx.test.ext:junit:1.1.1'
   androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
   }

这是 Gradle:(android 中的 python)

  buildscript {
  repositories {
    google()
    jcenter()
    maven { url "https://chaquo.com/maven" }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:4.0.1'
    classpath "com.chaquo.python:gradle:9.0.0"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
  }
 allprojects {
 repositories {
    google()
    centre()
 }
 }
 task clean(type: Delete) {
delete rootProject.buildDir
}

我已经链接了所有插件,正如 chaquopy 官方文档中提到的那样,我收到以下错误。

enter code here

   A problem occurred starting process 'command 'C:/Users/YASHWANTH''. Please set buildPython to your Python executable path. See https://chaquo.com/chaquopy/doc/current/android.html#buildpython.

删除时我没有收到上述错误

     python{
        pip{
            install "nltk"
        }
    }

所以请帮助我为什么在尝试安装任何 python 库时出现上述错误,

4

1 回答 1

0

buildPython在这个版本的 Chaquopy 中不能接受包含空格的文件名。这已在 Chaquopy 9.1.0 中修复

对于 Chaquopy 9.0.0 及更早版本:

如果您之前使用默认设置安装了 Python,py您的 PATH 中可能有可用的命令,Chaquopy 将自动使用该命令。尝试仅删除该buildPython行,看看它是否有效。

如果没有,请从python.org下载 Python并使用默认设置进行安装。然后你应该能够删除该buildPython行。

于 2020-11-11T12:29:40.297 回答