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

查看:2155
本文介绍了如何在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 Community Plugin.我也尝试在其他地方和指南中找到答案.但是到现在为止还没有运气.

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 Community Edition插件的一些功能才能在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.

如何将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天全站免登陆