大家好,
我正在使用 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 )) 时”。 我不确定究竟是什么导致了这个错误或如何修复它。
如果有人可以为这个问题提供见解或更好的解决方案,我将不胜感激。