大家好,
我正在使用 Application Builder 開發具有 Python 集成的應用程序。 我計劃將其編譯成一個加載項,以便能夠與其他用戶共享,但是,我需要一種方法來為所有用戶正確設置 Python 初始化。
我運行應用程序的方式只對我有用(用戶 EstelleS1 和我的環境, JMPPython環境) :
appNS:PythonPathText = "C:\Users\EstelleS1\AppData\Local\Programs\Python\Python37\JMPPythonEnvironment\Scripts\python37.dll";
appNS:PythonSysPathText = {"",
"C:\\Users\\EstelleS1\\AppData\\Local\\Programs\\Python\\Python37\\JMPPythonEnvironment\\Scripts\\python37.zip",
"C:\\Users\\EstelleS1\\AppData\\Local\\Programs\\Python\\Python37\\DLLs",
"C:\\Users\\EstelleS1\\AppData\\Local\\Programs\\Python\\Python37\\lib",
"C:\\Users\\EstelleS1\\AppData\\Local\\Programs\\Python\\Python37",
"C:\\Users\\EstelleS1\\AppData\\Local\\Programs\\Python\\Python37\\JMPPythonEnvironment",
"C:\\Users\\EstelleS1\\AppData\\Local\\Programs\\Python\\Python37\\JMPPythonEnvironment\\lib\\site-packages"};
Python Init(
Path( PythonPathText ),
Python Sys Path( PythonSysPathText )
);(appNS 指的是我的應用程序命名空間)
其他用戶將擁有很多管理員權限,因此我正在考慮設置一個工作流程,其中新用戶將單擊應用程序啟動器中的按鈕以上傳具有 Python 路徑和 sys 路徑字符串的文本文件,然後應用程序將採用這些文件並將副本保存在新文件夾中($DESKTOP 應該是所有用戶計算機上的可訪問位置)。
PythonPathButtonPress=Function({this},
// This function is called when the button is pressed
name = this << Get Button Name;
pickPythonPathFile = Pick File("Please select Python Path text file");
pickPythonSysPathFile = Pick File("Please select Python Sys Path text file");
PythonPathFile = Load Text File( pickPythonPathFile );
PythonSysPathFile = Load Text File( pickPythonSysPathFile );
PythonConfigFolder = ( "$DESKTOP/JMPPython Config/" );
NEWPythonPathFile = (PythonConfigFolder || "PythonPath.txt" );
NEWPythonSysPathFile = (PythonConfigFolder || "PythonSysPath.txt" );
PythonConfigDir = Create Directory( PythonConfigFolder );
Save Text File( NEWPythonPathFile, PythonPathFile );
Save Text File( NEWPythonSysPathFile, PythonSysPathFile );
);所以在第一次完成之後,用戶不需要再點擊按鈕來配置 Python。 然後在運行加載項的 Python 集成部分時,應用程序將自動搜索以在可訪問的文件夾位置(無論是 $DESKTOP 還是其他更好的位置)中打開這些複製的文件:
PythonPathFile = Convert File Path( "$DESKTOP\JMPPython Config\PythonPath.txt", search );
PythonSysPathFile = Convert File Path( "$DESKTOP\JMPPython Config\PythonSysPath.txt", search );
Try( appNS:PythonPathText = Load Text File( PythonPathFile ), New Window("Python Initialization Error", << Modal, Text Box("Need to configure Python first!") ); Throw() );
Try( appNS:PythonSysPathText = Load Text File( PythonSysPathFile ), New Window("Python Initialization Error", << Modal, Text Box("Need to configure Python first!") ); Throw() );
Python Init(
Path( PythonPathText ),
Python Sys Path( PythonSysPathText )
);但這一直沒有奏效。 我收到錯誤消息“找不到指定的模塊。在訪問或評估 'Python Init' 、Python Init/*###*/(Path( PythonPathText )、Python Sys Path( PythonSysPathText )) 時”。 我不確定究竟是什麼導致了這個錯誤或如何修復它。
如果有人可以為這個問題提供見解或更好的解決方案,我將不勝感激。