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

查看:185
本文介绍了在 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.

推荐答案

如果您只需要运行脚本而不需要编辑它们,最简单的方法是通过 Settings | 配置外部工具.工具 |外部工具.这不需要 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天全站免登陆