如何在 PyCharm 运行配置中运行 shell 脚本而不是

How can I run a shell script instead of python in a PyCharm run configuration?(如何在 PyCharm 运行配置中运行 shell 脚本而不是 python?)

本文介绍了如何在 PyCharm 运行配置中运行 shell 脚本而不是 python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 PyCharm 设置为调用 shell 脚本,而不是 python,作为运行选项.这可能吗?在默认选项中,我只有 Python、Python 文档和 Python 测试.有了专业版,我还有 Django 和其他人.但是,它们都将 python 作为组合框中的解释器,据我所知,它们无法更改.

I am trying to setup PyCharm to invoke a shell script, instead of python, as the run option. Is this possible? In the default options I only have Python, Python docs, and Python tests. With the professional edition I also have Django and others. However, they all have python as the interpreter in a combobox and they can't be changed as far as I can see.

推荐答案

如果你想在 PyCharm 中看到这样的功能,请投票 IDEA-112256命令行"运行配置功能请求.

If you want to see such a feature in PyCharm please vote on IDEA-112256 'Command Line' Run Configuration feature request.

运行/调试配置部分所有支持的运行/调试配置类型,并且确实不支持 shell 脚本.但是,您可以通过安装插件来添加此类支持.例如,如果您对 bash 脚本感兴趣,那么可以使用 BashSupport 插件来支持在运行/调试配置中运行 shell 脚本.

Run/Debug Configurations section of Pycharm's online help lists all supported types of Run/Debug configurations and there's no support for shell scripts indeed. However, you might be able to add such support by installing a plugin. For example, if you are interested in bash scripts there's BashSupport plugin which adds support for running shell scripts in Run/Debug configuration.

来自插件主页:

BashSupports 可以直接在 IntelliJ 中运行脚本.你可以创建Bash 脚本的新运行配置.在这里你可以设置哪个解释器用于运行它.每当执行脚本时输出被记录.如果 Bash 打印出语法错误,那么 errorneous行可点击跳转到错误的位置.

BashSupports can directly run scripts within IntelliJ. You can create a new run configuration for Bash scripts. Here you can set which interpreter is used to run it. Whenever a script is executed the output is logged. If Bash prints out syntax errors then the errorneous lines are clickable to jump to the location of the error.

对于 Windows,有 CmdSupport 插件,它提供了运行 .cmd 的操作脚本.但是,它似乎不支持运行诸如运行/调试配置之类的脚本.

For Windows there's CmdSupport plugin which provides an action to run .cmd scripts. It seems it does not support running such scripts as Run/Debug configuration however.

作为一种解决方法,您可以使用 Python 运行/调试配置,指定一些虚拟(空)Python 文件来运行并使用 Before launch 选项指定 外部工具 并指定路径添加/配置此外部工具时添加到脚本中.请参阅在 IntelliJ IDEA 中,如何创建一个键绑定以执行以当前文件为参数的 shell 脚本?详情.

As a workaround you can use Python run/debug configuration, specifying some dummy (empty) Python file to run and use Before launch option specifying External tool and specify path to the script when adding/configuring this external tool. See In IntelliJ IDEA, how can I create a key binding that executes a shell script with the current file as a parameter? for details.

由于 PyCharm 基于 IntelliJ 的 IDEA 平台,因此问题 IntelliJ IDEA: Running a shell script as a Run/Debug Configuration非常相关.

As PyCharm is based on IntelliJ's IDEA platform the question IntelliJ IDEA: Running a shell script as a Run/Debug Configuration is very related.

说到运行/调试配置,您可能对插件感兴趣 运行配置为 Action 其中

Speaking of run/debug configurations you might be interested in the plugin Run Configuration as Action which

(...) 提供了一种将运行配置用作工具栏上的按钮的方法.或者分配快捷方式来执行特定的运行配置.

(...) provides a way to use run configurations as buttons on toolbar. Or assign shortcuts to execute specific run configuration.

这篇关于如何在 PyCharm 运行配置中运行 shell 脚本而不是 python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在 PyCharm 运行配置中运行 shell 脚本而不是

基础教程推荐