为 NI TestStand 2022 Q4 安装 Python

更新 Jul 31, 2023

环境

软件

  • TestStand
  • Python Step Types for TestStand

其他

软件

  • TestStand

编程语言

  • Python

如果您想在 NI TestStand 中使用 Python 步骤,您首先需要安装 Python。下载 Python后,您将进行自定义安装以准备在 NI TestStand 中找到 Python。

以下指南介绍了如何为 NI TestStand 2022 Q4 安装 Python。它旨在适用于较旧(或较新)的 NI TestStand 版本,并稍作调整。

NI TestStand 由 2019 版本开始支持Python 步骤,对于旧版本的 NI TestStand,您将需要使用Calling Scripting Languages from NI TestStand

下载Python

1. 对于NI TestStand 2021 SP1和2022 Q4,除其他版本外,还支持Python 3.10。

支持的 Python 适配器:
NI TestStand 版本支持的Python版本
2022 Q43.7、3.8、3.9、3.10
2021 SP13.6、3.7、3.8、3.9、3.10


2. 如果您想选择Python 3.10,请前往Python 3.10下载页面

A:选择与 NI TestStand 相同的 Python 位数。 (有关原因的更多信息,请参阅Using Both LabVIEW 32-Bit and 64-Bit in TestStand - 在这方面,Python 适配器的行为与 LabVIEW 适配器非常相似)

B:下载 Windows 安装程序。
 

安装Python

1.开始安装

2. 确保选中Add python.exe to PATH复选框。为了让 TestStand 找到 Python 解释器,需要将 Python 添加到PATH 环境变量。

3. 选择Customize Installation

01_定制安装.png

4. 在Advanced Options设置中,
A:为所有用户安装
B:
安装在“C:\Program Files”或“C:\Program Files (86)”以外的位置。

02_定制安装.png


在 TestStand 中设置 Python 适配器

1. 在 Teststand 文件菜单中,转到Configure >> Adapters… >> Python >> Configure…

2.选择您安装的Python版本

03_Python版本.png

3. 您可能需要检查Display console for interpreter sessions

注意:如果您选中Display console for interpreter sessions ,则在适配器调用期间将打开控制台窗口,并且将显示 print() 命令。通常建议不要选中此复选框进行部署,因为那样您将需要手动处理控制台弹出窗口。另请记住,不要手动关闭控制台窗口 - 如果这样做,Python 适配器将会崩溃,并且您需要先Unload all modules,然后才能再次使用 Python 适配器。

4. 您可能想使用virtualenv来使用虚拟环境。请参阅知识库文章TestStand's Python Adapter Configuration Shows Invalid Virtual Environment Path以了解更多信息。

有关 Python 适配器配置的更多信息,请参阅NI TestStand Help >> Python Adapter


完毕

您已完成 NI TestStand 的 Python 安装。您可以在下面的相关链接部分找到 TestStand 步骤的 Python 示例。

下一步