如何在android studio中配置Python解释器 [英] How to configure Python interpretor in android studio

查看:254
本文介绍了如何在android studio中配置Python解释器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 android studio 中的 python 用作处理变量和生成答案的后端代码.我的 MainActivity 在 Java 中,并为 python 代码创建了一个目录.当我尝试用 python 编写代码时,提示没有为模块配置 python 解释器",我添加了 Chaquopy 和 Python 社区插件.另外我想知道如何将 MainActivity 的变量发送到 python,反之亦然.

I am trying to se python in android studio as a backend code for working on variables and producing answer. My MainActivity is in Java and a directory is created for python code. when I try to write code in python is tells that "no python interpreter configured for the module" I have added Chaquopy and Python Community Plugin. Also I want to know how can I send variables for my MainActivity to python and viceversa.

我正在尝试在 android studio 中添加 python.我尝试过 Chaquopy 和 Python 社区插件.我也试图在不同的地方和指南上找到答案.但直到现在还没有运气.

I am trying to add python in android studio. I have tried Chaquopy and also Python Community Plugin. I have tried to find answers on different places and guides too. But no Luck till now.

buildscript {
    repositories {
        google()
        jcenter()
        maven{url "https://chaquo.com/maven"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "com.chaquo.python:gradle:0.5.0"
    }
}

这是 MainActivity,我想将变量a"发送到 python 文件以进行处理.

this is MainActivity and I want to send my variable "a" to python file to work on it.

package com.example.testingpython;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    int a=2;
    String[] array={"My","Name","Java"};

}

}

推荐答案

当我尝试用 python 编写代码时,提示没有为模块配置 python 解释器"

when I try to write code in python is tells that "no python interpreter configured for the module"

只有 Python 社区版插件的一些功能可以在 Android Studio 中正常工作.如果需要,您仍然可以在 Android Studio 中编写 Python 代码,但大部分 IDE 帮助将不可用.

Only a few features of the Python Community Edition plugin will work properly in Android Studio. You can still write your Python code in Android Studio if you want, but most of the IDE assistance will be unavailable.

即使代码显示错误指示符,您仍然可以继续运行您的应用程序,如果任何错误是真实的,详细信息将显示在 Logcat.

Even if the code displays error indicators, you can still go ahead and run your app, and if any of the errors are real, the details will be displayed in the Logcat.

如何将 MainActivity 的变量发送到 python,反之亦然.

how can I send variables for my MainActivity to python and viceversa.

请参阅 Chaquopy 文档演示应用.

See the example code in the Chaquopy documentation and demo app.

这篇关于如何在android studio中配置Python解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆