Hi All,
I am using Application Builder to develop an application with Python integration. I plan on compiling this into an add-in to be able to share with other users, however, I need a way to correctly set up the Python initialization for all users.
The way I have been running the application will only work for me (user EstelleS1 and my environment, JMPPythonEnvironment)
:
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 refers to my application namespace)
The other users will have a lot of admin privileges so I was thinking of setting up a workflow where a new user will click a button in the app launcher to upload text files with the Python path and sys path strings, then the application will take those files and save copies in a new folder (where $DESKTOP should be an accessible location on all users' computers).
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 );
);
So after this is done the first time, the user shouldn't need to click the button to configure Python again after that. And then upon running the add-in's Python integration parts, the application will automatically search to open these copied files in the accessible folder location (whether that is $DESKTOP or something else better):
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 )
);
But this has not been working. I have been getting the error "The specified module could not be found. in access or evaluation of 'Python Init' , Python Init/*###*/(Path( PythonPathText ), Python Sys Path( PythonSysPathText ))". I am not sure exactly what is causing this error or how to fix it.
I would appreciate if anyone can give insight or a better solution to this problem.