python文本菜单程序_为 Python 项目定义自定义菜单命令 - Visual Studio | Microsoft Docs...

为 Python 项目定义自定义命令Define custom commands for Python projects

11/12/2018

JoshuaPartlow.png?size=32

olprod.png?size=32

本文内容

在处理 Python 项目的过程中,可观察到系统切换到命令窗口来运行特定脚本或模块、运行 pip 命令或运行一些其他任意工具。In the process of working with your Python projects, you may find yourself switching to a command window to run specific scripts or modules, run pip commands, or run some other arbitrary tool. 为改进工作流,可将自定义命令添加到 Python 项目上下文菜单的 Python 子菜单中。To improve your workflow, you can add custom commands to the Python submenu in the Python project context menu. 可在控制台窗口或 Visual Studio“输出”窗口中运行这些命令。Those commands can run in a console window or in the Visual Studio Output window. 还可使用正则表达式来指示 Visual Studio 如何分析来自命令输出的错误和警报。You can also use regular expressions to instruct Visual Studio how to parse errors and warnings from the command's output.

默认情况下,此菜单仅包含单个 Run PyLint 命令:By default, that menu contains only the single Run PyLint command:

custom-commands-default-menu.png?view=vs-2019

自定义命令也显示在此上下文菜单中。Custom commands appear in this same context menu. 直接向项目文件添加自定义命令,这些命令在此处应用到上述单个项目中。Custom commands are added to a project file directly, where they apply to that individual project. 还可在 .targets 文件中定义自定义命令,这些命令可轻松导入多个项目文件。You can also define custom commands in a .targets file that can easily be imported into multiple project files.

Visual Studio 中的某些 Python 项目模板已使用其 .targets 文件添加其自身的自定义命令。Certain Python project templates in Visual Studio already add custom commands of their own using their .targets file. 例如,Bottle Web 项目和 Flask Web 项目模板均添加“启动服务器”和“启动调试服务器”这两个命令 。For example, the Bottle Web Project and Flask Web Project templates both add two commands, Start server and Start debug server. Django Web 项目模板也会添加这些命令,但还会再添加一些项:The Django Web Project template adds these same commands plus quite a few more:

custom-commands-django-menu.png?view=vs-2019

每个自定义命令都可引用 Python 文件、Python 模块、内联 Python 代码、任意可执行文件或 pip 命令。Each custom command can refer to a Python file, a Python module, inline Python code, an arbitrary executable, or a pip command. 还可指定命令运行的方式和位置。You can also specify how and where the command runs.

提示

每次在文本编辑器中更改项目文件时,都必须在 Visual Studio 中重新加载项目才能应用这些更改。Whenever you make changes to a project file in a text editor, it's necessary to reload the project in Visual Studio to apply those changes. 例如,必须先重新加载项目,才能向要在项目上下文菜单上显示的这些命令添加自定义命令。For example, you must reload a project after adding custom command definitions for those commands to appear on the project's context menu.

如你所知,Visual Studio 提供直接编辑项目文件的方式。As you may know, Visual Studio provides a means to edit the project file directly. 首先右键单击项目文件并选择“卸载项目”,然后再次右键单击并选择“编辑 ”,才能在 Visual Studio 编辑器中打开项目 。You first right-click the project file and select Unload project, then right-click again and select Edit to open the project in the Visual Studio editor. 然后,编辑内容并进行保存,再次右键单击项目,再选择“重新加载项目”,此时系统也会提示你确认关闭编辑器中的项目文件。You then make and save edits, right-click the project once more, and select Reload project, which also prompts you to confirm closing the project file in the editor.

但在开发自定义命令时,所有这些单击都变得繁琐。When developing a custom command, however, all these clicks can become tedious. 要提升工作流效率,请在 Visual Studio 中加载项目,并同时在单独的编辑器中一并打开 .pyproj 文件(例如 Visual Studio、Visual Studio Code 和记事本等的其他实例)。For a more efficient workflow, load the project in Visual Studio and also open the .pyproj file in a separate editor altogether (such as another instance of Visual Studio, Visual Studio Code, Notepad, etc.). 保存在编辑器中所做的更改并切换到 Visual Studio 时,Visual Studio 会检测更改,并询问是否要重新加载项目(已在环境外部修改项目 )。When you save changes in the editor and switch to Visual Studio, Visual Studio detects changes and asks whether to reload the project (The project has been modified outside the environment.). 选择“重新加载”,只需一步即可应用所做更改。Select Reload and your changes are immediately applied in just one step.

演练:向项目文件添加命令Walkthrough: Add a command to a project file

此部分将演示一个使用 python.exe 直接运行项目启动文件的简单示例,有助于熟悉自定义命令。To familiarize yourself with custom commands, this section walks through a simple example that runs a project's startup file directly using python.exe. (此类命令的作用等同于使用“调试” > “启动但不调试” 。)(Such a command is effectively the same as using Debug > Start without Debugging.)

使用“Python 应用程序”模板新建一个名为“Python-CustomCommands”的项目。Create a new project named "Python-CustomCommands" using the Python Application template. (如果尚不熟悉流程,请参阅快速入门:基于模板创建 Python 项目以获取相关说明。)(See Quickstart: Create a Python project from a template for instructions if you're not already familiar with the process.)

在 Python_CustomCommands.py 中,添加代码 print("Hello custom commands")。In Python_CustomCommands.py, add the code print("Hello custom commands").

在“解决方案资源管理器”中右键单击项目,再选择“Python”。请注意,子菜单中仅显示 Run PyLint 命令 。Right-click the project in Solution Explorer, select Python, and notice that the only command that appears on the submenu is Run PyLint. 自定义命令也显示在此子菜单上。Your custom commands appear on this same submenu.

根据说明中建议的操作,在单独的文本编辑器中打开 Python-CustomCommands.pyproj。As suggested in the introduction, open Python-CustomCommands.pyproj in a separate text editor. 然后,在恰好位于结尾的 内的文件末尾添加以下行,然后保存文件。Then add the following lines at the end of the file just inside the closing and save the file.

$(PythonCommands);

切换回到 Visual Studio,并在系统提示出现文件更改时选择“重新加载”。Switch back to Visual Studio and select Reload when it prompts you about the file change. 然后再次检查“Python”菜单,查看 Run PyLint 是否仍是此处显示的唯一项,因为所添加的行仅复制包含 PyLint 命令的默认 属性组 。Then check the Python menu again to see that Run PyLint is still the only item shown there because the lines you added only replicate the default property group containing the PyLint command.

通过项目文件切换到编辑器,并在 的后面添加以下 定义。Switch to the editor with the project file and add the following definition after the . 如本文稍后所述,此 Target 元素定义一个在控制台窗口使用 python.exe 运行启动文件(由“StartupFile”属性标识)的自定义命令。As explained later in this article, this Target element defines a custom command to run the startup file (identified by the "StartupFile" property) using python.exe in a console window. 此 ExecuteIn="consolepause" 属性使用一个在你按键后才关闭的控制台。The attribute ExecuteIn="consolepause" uses a console that waits for you to press a key before closing.

TargetType="script"

Target="$(StartupFile)"

Arguments=""

WorkingDirectory="$(MSBuildProjectDirectory)"

ExecuteIn="consolepause">

将目标的 Name 属性的值添加到之前添加的 属性组,让元素如以下代码所示。Add the value of the Target's Name attribute to the property group added earlier, so that the element looks like the code below. 将目标名称添加到此列表就是指将其添加到 Python 菜单。Adding the name of the target to this list is what adds it to the Python menu.

$(PythonCommands);

Example_RunStartupFile

如果希望命令显示在 $(PythonCommands) 中定义的项之前,请将其放在此标记的前面。If you want your command to appear before those defined in $(PythonCommands), place them before that token.

保存项目文件,切换到 Visual Studio,然后在系统提示时重新加载项目。Save the project file, switch to Visual Studio, and reload the project when prompted. 右键单击“Python-CustomCommands”项目并选择“Python” 。Then right-click the Python-CustomCommands project and select Python. 菜单上应该会显示“运行启动文件”项。You should see a Run startup file item on the menu. 如果未显示菜单项,请检查是否已将名称添加到 元素。If you don't see the menu item, check that you added the name to the element. 另请参阅本文稍后部分中的疑难解答。Also see Troubleshooting later in this article.

custom-commands-walkthrough-menu-item.png?view=vs-2019

选择“运行启动文件”命令,此时应会显示一个命令窗口,窗口上显示“了解自定义命令”且后接“按任意键继续操作 。Select the Run startup file command and you should see a command window appear with the text Hello custom commands followed by Press any key to continue. 按相关键关闭窗口。Press a key to close the window.

custom-commands-walkthrough-console.png?view=vs-2019

通过项目文件返回到编辑器,并将 ExecuteIn 属性的值更改为 output。Return to the editor with the project file and change the value of the ExecuteIn attribute to output. 保存文件,切换到 Visual Studio,再重新加载项目,然后再次调用命令。Save the file, switch to Visual Studio, reload the project, and invoke the command again. 此时,Visual Studio 的“输出”窗口中会显示项目的输出:This time you see the program's output appear in Visual Studio's Output window:

custom-commands-walkthrough-output-window.png?view=vs-2019

要添加更多命令,请为每个命令定义适当的 元素,将目标的名称添加到 属性组,并在 Visual Studio 中重新加载项目。To add more commands, define a suitable element for each command, add the name of the target into the property group, and reload the project in Visual Studio.

提示

如果调用要使用项目属性的命令(例如 ($StartupFile)),且此命令由于标记未定义而失败,则在你重新加载项目之前,Visual Studio 会禁用此命令。If you invoke a command that uses project properties, such as ($StartupFile), and the command fails because the token is undefined, Visual Studio disables the command until you reload the project. 但是,更改会定义属性的项目之后,不会刷新这些命令的状态,因此仍需在此类情况下重新加载项目。Making changes to the project that would define the property, however, does not refresh the state of these commands, so you still need to reload the project in such cases.

命令目标结构Command target structure

元素通常按以下伪代码形式显示:The general form of the element is shown in the following pseudo-code:

TargetType="executable/script/module/code/pip"

Arguments="..."

ExecuteIn="console/consolepause/output/repl[:Display name]/none"

WorkingDirectory="..."

ErrorRegex="..."

WarningRegex="..."

RequiredPackages="...;..."

Environment="...">

若要在属性值中引用项目属性或环境变量,请使用 $() 标记中的名称,例如 $(StartupFile) 和 $(MSBuildProjectDirectory)。To refer to project properties or environment variables in attribute values, use the name within a $() token, such as $(StartupFile) and $(MSBuildProjectDirectory). For more information, see MSBuild properties.

Target 属性Target attributes

特性Attribute

必需Required

描述Description

“属性”Name

是Yes

Visual Studio 项目中命令的标识符。The identifier for the command within the Visual Studio project. 必须将此名称添加到 组,Python 子菜单上才会显示命令。This name must be added to the property group for the command to appear on the Python submenu.

LabelLabel

是Yes

Python 子菜单中出现的 UI 显示名称。The UI display name that appears in the Python sub-menu.

返回Returns

是Yes

必须包含将目标标识为命令的 @(Commands)。Must contain @(Commands), which identifies the target as a command.

CreatePythonCommandItem 属性CreatePythonCommandItem attributes

属性值均不区分大小写。All attribute values are case-insensitive.

特性Attribute

必需Required

描述Description

TargetTypeTargetType

是Yes

指定 Target 属性包含的内容以及如何将其与 Arguments 属性一并使用:Specifies what the Target attribute contains and how it's used along with the Arguments attribute:可执行文件: 运行在 Target 中命名的可执行文件,附加 Arguments 的值,就如在命令行中直接输入一般。executable: Run the executable named in Target, appending the value in Arguments, as if entered directly on the command line. 值仅可包含项目名称且不可带有参数。The value must contain only a program name without arguments.

脚本:向 Target 中的文件名运行 python.exe,再执行 Arguments 中的值。script: Run python.exe with the filename in Target, followed with the value in Arguments.

模块:在 Target 中运行后接模块名的 python -m,再运行 Arguments 中的值。module: Run python -m followed by the module name in Target, followed with the value in Arguments.

代码:运行 Target 中包含的内联代码。code: Run the inline code contained in Target. 这会忽略 Arguments 值。The Arguments value is ignored.

pip:通过 Target 中的命令运行 pip,后接 Arguments;但如果 ExecuteIn 设置为“输出”,pip 则假定 install 命令并使用 Target 作为包名称。pip: Run pip with the command in Target, followed by Arguments; is ExecuteIn is set to "output", however, pip assumes the install command and uses Target as the package name.

目标Target

是Yes

要使用的文件名、模块名、代码或 pip 命令(取决于 TargetType)。The filename, module name, code, or pip command to use, depending on the TargetType.

自变量Arguments

可选Optional

指定要赋值给目标的参数字符串(若有)。Specifies a string of arguments (if any) to give to the target. 请注意,如果 TargetType 是 script,则向 Python 项目赋予参数,而不是 python.exe。Note that when TargetType is script, the arguments are given to the Python program, not python.exe. code TargetType 忽略此项。Ignored for the code TargetType.

ExecuteInExecuteIn

是Yes

指定要运行命令的环境:Specifies the environment in which to run the command:控制台:(默认)如同直接在命令行上直接输入 Target 和 Arguments 一样运行它们。console: (Default) Runs Target and the arguments as if they are entered directly on the command line. 这会在运行 Target 时显示命令窗口,该窗口随后自动关闭。A command window appears while the Target is running, then is closed automatically.

consolepause:与控制台相同,但必须按键才能关闭窗口。consolepause: Same as console, but waits for a keypress before closing the window.

输出:运行 Target 并在 Visual Studio 的“输出”窗口中显示其结果。output: Runs Target and displays its results in the Output window in Visual Studio. 如果 TargetType 为“pip”,则 Visual Studio 使用 Target 作为包名称并附加 Arguments。If TargetType is "pip", Visual Studio uses Target as the package name and appends Arguments.

repl:在 Python 交互式窗口中运行 Target;可选显示名称用作窗口的标题。repl: Runs Target in the Python Interactive window; the optional display name is used for the title of the window.

无:与控制台的行为相同。none: behaves the same as console.

WorkingDirectoryWorkingDirectory

可选Optional

要在其中运行命令的文件夹。The folder in which to run the command.

ErrorRegexErrorRegex

WarningRegExWarningRegEx

可选Optional

仅可在 ExecuteIn 为 output 时使用。Used only when ExecuteIn is output. 这两个值均指定一个正则表达式,Visual Studio 使用此表达式来分析命令输出,以在“错误列表”窗口中显示错误和警报。Both values specify a regular expression with which Visual Studio parses command output to show errors and warnings in its Error List window. 若未指定,则命令不会影响“错误列表”窗口。If not specified, the command does not affect the Error List window. 有关 Visual Studio 所需内容的详细信息,请参阅命令的捕获组。For more information on what Visual Studio expects, see Named capture groups.

RequiredPackagesRequiredPackages

可选Optional

命令的包请求列表,其中命令的格式与 requirements.txt 相同 (pip.readthedocs.io)。A list of package requirements for the command using the same format as requirements.txt (pip.readthedocs.io). “运行 PyLint”命令,例如指定 pylint>=1.0.0。The Run PyLint command, for example specifies pylint>=1.0.0. 运行命令之前,Visual Studio 会先检查是否已安装列表中的所有包。Before running the command, Visual Studio checks that all packages in the list are installed. Visual Studio 使用 pip 命令来安装缺少的包。Visual Studio uses pip to install any missing packages.

环境Environment

可选Optional

运行命令前要定义的环境变量的字符串。A string of environment variables to define before running the command. 每个变量均使用 = 形式,多个变量用分号隔开。Each variable uses the form = with multiple variables separated by semicolons. 具有多个值的变量必须用单引号或双引号引起来,例如 'NAME=VALUE1;VALUE2' 形式。A variable with multiple values must be contained in single or double quotes, as in 'NAME=VALUE1;VALUE2'.

正则表达式中已命名的捕获组Named capture groups for regular expressions

在分析来自命令输出的错误和警报时,Visual Studio 期望 ErrorRegex 和 WarningRegex 值中的正则表达式使用以下命名组:When parsing error and warnings from a command's output, Visual Studio expects that the regular expressions in the ErrorRegex and WarningRegex values use the following named groups:

(?...):错误文本(?...): Text of the error

(?...):错误代码(?...): Error code

(?...):报告其出现错误的文件的名称(?...): Name of the file for which the error is reported

(?...):报告其出现错误的文件的位置行号。(?...): Line number of the location in the file for which the error reported.

(?...):报告其出现错误的文件的位置列号。(?...): Column number of the location in the file for which the error reported.

例如,PyLint 生成以下形式的警报:For example, PyLint produces warnings of the following form:

************* Module hello

C: 1, 0: Missing module docstring (missing-docstring)

“运行 Pylint”命令的 WarningRegex 值必须如下所示,Visual Studio 才能从此类警报中提取正确的信息并将其显示在“错误列表”窗口中 :To allow Visual Studio to extract the right information from such warnings and show them in the Error List window, the WarningRegex value for the Run Pylint command is as follows:

^(?.+?)\((?\d+),(?\d+)\): warning (?.+?): (?.+?)$]]

(请注意:值中的 msg_id 实际上应为 code具体请参见问题 3680。)(Note that msg_id in the value should actually be code, see Issue 3680.)

使用自定义命令创建 .targets 文件Create a .targets file with custom commands

如果在项目文件中定义自定义命令,则该命令仅在此项目文件中可用。Defining custom commands in a project file makes them available to only that project file. 要在多个项目文件中使用命令,必须在 .targets 文件中定义 属性组以及所具备的所有 元素。To use commands in multiple project files, you instead define the property group and all your elements in a .targets file. 然后将此文件导入到单个项目文件中。You then import that file into individual project files.

.targets 文件采用以下格式:The .targets file is formatted as follows:

$(PythonCommands);

要将 .targets 文件加载到项目中,需将 元素置于 元素中(位置不限)。To load a .targets file into a project, place a element anywhere within the element. 例如,如果项目的 targets 子文件夹中具有名为 CustomCommands.targets 的文件,请使用以下代码 :For example, if you have a file named CustomCommands.targets in a targets subfolder in your project, use the following code:

备注

每次更改 .targets 文件时,都需要重新加载包含项目的解决方案,而不是加载项目本身 。Whenever you change the .targets file, you need to reload the solution that contains a project, not just the project itself.

示例命令Example commands

运行 PyLint(模块目标)Run PyLint (module target)

以下代码显示在 Microsoft.PythonTools.targets 文件中:The following code appears in the Microsoft.PythonTools.targets file:

$(PythonCommands);PythonRunPyLintCommand

^(?<filename>.+?)\((?<line>\d+),(?<column>\d+)\): warning (?<msg_id>.+?): (?<message>.+?)$

Label="resource:Microsoft.PythonTools.Common;Microsoft.PythonTools.Common.Strings;RunPyLintLabel"

Returns="@(Commands)">

TargetType="module"

Arguments=""--msg-template={abspath}({line},{column}): warning {msg_id}: {msg} [{C}:{symbol}]" -r n @(Compile, ' ')"

WorkingDirectory="$(MSBuildProjectDirectory)"

ExecuteIn="output"

RequiredPackages="pylint>=1.0.0"

WarningRegex="$(PyLintWarningRegex)">

向特定的包(pip 目标)运行 pip installRun pip install with a specific package (pip target)

以下命令在“输出”窗口运行 pip install my-package。The following command runs pip install my-package in the Output window. 可在开发包和测试其安装项的情况下运行此命令。You might use such a command when developing a package and testing its installation. 请注意,Target 中具有包名称而不是 install 命令,使用 ExecuteIn="output" 时假定为后者。Note that Target contains the package name rather than the install command, which is assumed when using ExecuteIn="output".

$(PythonCommands);InstallMyPackage

WorkingDirectory="$(MSBuildProjectDirectory)" ExecuteIn="output">

显示过时的 pip 包(pip 目标)Show outdated pip packages (pip target)

$(PythonCommands);ShowOutdatedPackages

WorkingDirectory="$(MSBuildProjectDirectory)" ExecuteIn="consolepause">

通过 consolepause 运行可执行文件Run an executable with consolepause

以下命令只需运行 where 即可显示出在项目文件夹中启动 Python 文件:The following command simply runs where to show Python files starting in the project folder:

$(PythonCommands);ShowAllPythonFilesInProject

WorkingDirectory="$(MSBuildProjectDirectory)" ExecuteIn="output">

运行服务器和调试服务器命令Run server and run debug server commands

要了解如何为 Web 项目定义“启动服务器”和“启动调试服务器”命令,请查看 Microsoft.PythonTools.Web.targets (GitHub) 。To explore how the Start server and Start debug server commands for web projects are defined, examine the Microsoft.PythonTools.Web.targets (GitHub).

安装开发程序包Install package for development

PipInstallDevCommand;$(PythonCommands);

WorkingDirectory="$(WorkingDirectory)" ExecuteIn="Repl:Install package for development">

生成 Windows InstallerGenerate Windows installer

$(PythonCommands);BdistWinInstCommand;

Arguments="bdist_wininst --user-access-control=force --title "$(InstallerTitle)" --dist-dir="$(DistributionOutputDir)""

WorkingDirectory="$(WorkingDirectory)" RequiredPackages="setuptools"

ExecuteIn="Repl:Generate Windows Installer">

生成滚轮程序包Generate wheel package

$(PythonCommands);BdistWheelCommand;

Arguments="bdist_wheel --dist-dir="$(DistributionOutputDir)""

WorkingDirectory="$(WorkingDirectory)" RequiredPackages="wheel;setuptools"

ExecuteIn="Repl:Generate Wheel Package">

疑难解答Troubleshooting

消息:“无法加载项目文件”Message: "The project file could not be loaded"

表示项目文件中存在语法错误。Indicates that you have syntax errors in the project file. 此消息包含具有行号和字符位置的具体错误。The message includes the specific error with a line number and character position.

运行命令后立即关闭控制台窗口Console window closes immediately after command is run

使用 ExecuteIn="consolepause" 而非 ExecuteIn="console"。Use ExecuteIn="consolepause" instead of ExecuteIn="console".

菜单中未显示命令Command does not appear on the menu

检查命令是否包含在 属性组中,以及命令列表中的名称是否与 元素中指定的元素相匹配。Check that the command is included in the property group, and that the name in the command list matches the name specified in the element.

例如在下例中,属性组中的“Example”名称与目标中的“ExampleCommand”名称不匹配。For example, in the following elements, the "Example" name in the property group does not match the name "ExampleCommand" in the target. Visual Studio 未找到名为“Example”的命令,因此不显示任何命令。Visual Studio does not find a command named "Example", so no command appears. 请在命令列表中使用“ExampleCommand”,或只将目标的名称更改为“Example”。Either use "ExampleCommand" in the command list, or change the name of the target to "Example" only.

$(PythonCommands);Example

消息:“运行 时出错。Message: "An error occurred while running . 未能从项目中获取命令 。”Failed to get command from project."

表示 或 元素中的内容不正确。Indicates that the contents of the or elements are incorrect. 原因可能为:Possible reasons include:

所需的 Target 属性为空。The required Target attribute is empty.

所需的 TargetType 属性为空或包含不可识别的值。The required TargetType attribute is empty or contains an unrecognized value.

所需的 ExecuteIn 属性为空或包含不可识别的值。The required ExecuteIn attribute is empty or contains an unrecognized value.

指定了 ErrorRegex 或 WarningRegex,但未指定 ExecuteIn="output" 设置。ErrorRegex or WarningRegex is specified without setting ExecuteIn="output".

元素中存在不可识别的属性。Unrecognized attributes exist in the element. 例如,可能使用了 Argumnets(拼写错误)而不是 Arguments。For example, you may have used Argumnets (misspelled) instead of Arguments.

如果引用未定义的属性,则属性值可能为空。Attribute values can be empty if you refer to a property that's not defined. 例如,例如使用 $(StartupFile) 标记,但未在项目中定义任何启动文件,则标记解析为空字符串。For example, if you use the token $(StartupFile) but no startup file has been defined in the project, then the token resolves to an empty string. 此类情况下,可能需要定义一个默认值。In such cases, you may want to define a default value. 例如,如果尚未在项目属性中指定服务器启动文件,则在 Bottle,Flask 和 Django 项目模板中定义的“Run server”和“Run debug server”命令将默认为 manage.py 。For example, the Run server and Run debug server commands defined in the Bottle, Flask, and Django project templates default to manage.py if you haven't otherwise specified a server startup file in the project properties.

运行命令时,Visual Studio 停止响应且出现崩溃Visual Studio stops responding and crashes when running the command

你可能在尝试通过 ExecuteIn="output" 运行控制台命令,此时 Visual Studio 可能在尝试分析输出时崩溃。You're likely attempting to run a console command with ExecuteIn="output", in which case Visual Studio may crash trying to parse the output. 请改用 ExecuteIn="console"。Use ExecuteIn="console" instead.

可执行命令“未被识别为内部或外部命令、可操作程序或批处理文件”Executable command "is not recognized as an internal or external command, operable program or batch file"

使用 TargetType="executable" 时,Target 中的值只能是不带任何参数的程序名称,例如仅为 python 或仅为 python.exe 。When using TargetType="executable", the value in Target must be only the program name without any arguments, such as python or python.exe only. 将所有参数移动到 Arguments 属性中。Move any arguments to the Arguments attribute.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值