在 LabVIEW 中使用 Python Node 和 TensorFlow 時遇到錯誤 1667

更新 Jan 2, 2025

產品資訊

軟體

  • LabVIEW

程式語言

  • Python

問題敘述

當我使用Python節點呼叫導入TensorFlow模組的Python功能時,LabVIEW顯示錯誤1667: 

"AttributeError: module 'sys' has not attribute 'argv'. 

圖片.png

解決方案

要解決這個特定的 Python 錯誤:

  1. 確保您已安裝Python 2.7或3.6版本。
  2. 複製以下程式碼:
import sys

if not hasattr(sys, 'argv'):
    sys.argv = ['']

 

  1. 將複製的程式碼貼到位於下列路徑的library“multi_process_lib.py”中:

             C:\Users\YOUR USER\AppData\Local\Programs\Python\Python36(or 27)\Lib\
             site-packages\tensorflow\python\distribute


最終程式碼應如下所示:

圖片.png

注意:確保 sys.argv = [''] 行有一個縮排(從行開頭開始的空格),如果將遊標放在該行的開頭並按鍵盤上的 Tab 鍵,就可以做到這一點。
  1. 儲存並再次執行 LabVIEW 程式。