下載Python
1. 使用下表確定您的 NI TestStand 版本支援的 Python 版本。
支援的 Python Adapter:
NI TestStand 版本 | 支援的Python版本 |
---|
2024 Q4 | 3.8、3.9、3.10、3.11、3.12 |
2023 Q4 | 3.8、3.9、3.10、3.11 |
2022 Q4 | 3.7、3.8、3.9、3.10 |
2021 SP1 | 3.6、3.7、3.8、3.9、3.10 |
2. 下載Python 的 Windows 安裝程式。
安裝Python
1. 執行Python安裝程式。
2. 確保選取「Add python.exe to PATH」勾選框,這麼做是為了讓 TestStand 能找到 Python 直譯器,所以我們需要將 Python 加入PATH 環境變數。
3. 選擇自訂安裝。
4. 在進階選項設定中:
- 為所有使用者啟用安裝。
- 安裝在「C:\Program Files」或「C:\Program Files (86)」以外的位置,如下所示。
在 TestStand 中設定 Python Adapter
1. 在 Teststand 檔案選單中,點擊 Configure >> Adapters… >> Python >> Configure…
2. 選擇您安裝的Python版本。
3. 視您的需要來要勾選 Display console for interpreter sessions. 。
注意:如果您選取「 Display console for interpreter sessions 」 ,則在Adapter呼叫期間將開啟控制台視窗,並且將顯示 print() 命令。通常建議不要選取此核取方塊進行佈署,因為那樣您將需要手動處理控制台彈出視窗。另請記住,不要手動關閉控制台視窗 - 如果這樣做,Python Adapter將會crash,並且您需要先Unload all modules ,然後才能再次使用 Python Adapter。
4. 您可能會想要使用virtualenv來使用虛擬環境。請參閱知識library文章 TestStand 的 Python Adapter設定顯示無效的虛擬環境路徑,以了解更多資訊。
有關 Python Adapter設定的更多資訊,請參閱NI TestStand 幫助 >> Python Adapter。
完成
您已完成 NI TestStand 的 Python 安裝。您可以在下面的相關連結部份找到 TestStand 步驟的 Python 範例。