在Android Studio中运行Python脚本 [英] Running Python scripts inside Android Studio

查看:1688
本文介绍了在Android Studio中运行Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Android Studio 2.2.3

I am running Android Studio 2.2.3

在开发过程中,我需要运行Python脚本来处理一些数据文件.最终的apk不需要在设备中运行Python.

I need to run Python scripts during my development to process some data files. The final apk does not need to run Python in the device.

目前,我是从终端或PyDev for Eclipse运行脚本的,但是我正在寻找从Android Studio实现脚本的方法.

At the moment I run the scripts from a terminal or from PyDev for Eclipse, but I was looking for a way of doing it from Android Studio.

似乎有一种方法可以执行此操作,因为当我右键单击.py文件并选择运行"选项时,将打开编辑配置"对话框,在其中可以配置多个选项.问题是我无法指定Python解释器,而必须从已经配置的Python SDK的组合框中选择它.虽然没有选择解释器,但会显示一条错误消息,指出 错误:请选择具有有效Python SDK的模块" .

There seems to be a way to do this, as when I right-click on a .py file and select the 'Run' option, an 'Edit configuration' dialog opens where I can configure several options. The problem is that I cannot specify the Python interpreter, having to select it from a combo box of already configured Python SDKs. While there is no interpreter selected, there is an error message stating "Error: Please select a module with a valid Python SDK".

我设法为我的项目创建了Java模块,但没有为Python创建模块(我确实安装了Python Community Edition插件).有人知道如何实现吗?

I managed to create Java modules for my project, but not Python ones (I do have the Python Community Edition plugin installed).Does anybody know how to achieve this?.

TIA.

推荐答案

如果您只需要运行脚本而无需对其进行编辑,那么最简单的方法是通过设置" |配置"来配置外部工具.工具|外部工具.这不需要Python插件或任何特定于Python的配置.您只需指定要执行的命令行即可.外部工具在工具"菜单中显示为项目,您也可以使用设置" |键盘"为它们分配键盘快捷键.键盘映射.

If you only need to run the scripts and not to edit them, the easiest way to do so is to configure an external tool through Settings | Tools | External Tools. This doesn't require the Python plugin or any Python-specific configuration; you can simply specify the command line to execute. External tools appear as items in the Tools menu, and you can also assign keyboard shortcuts to them using Settings | Keymap.

这篇关于在Android Studio中运行Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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