[Ra...] Posted October 9 Share Posted October 9 I have a rather large Python script that uses multiple files in sub-folders. When I am working on the App all the included sub scripts load fine, but when I run the script after hitting the "Finalize App" the script stops with the error that the imported scripts are not found. Is there something I'm missing? I am currently working in V2025. Thanks. Link to comment Share on other sites More sharing options...
[Ma...] Posted October 9 Share Posted October 9 How are you linking your scripts? Link to comment Share on other sites More sharing options...
[Ra...] Posted October 9 Author Share Posted October 9 Typically I link the path into "sys.path" # # Add the class and imports folders for setting the import locations myclassPath = os.path.join (sys.path[0],'classes') myimportPath = os.path.join (sys.path[0],'imports') sys.path.append(myclassPath) sys.path.append(myimportPath) # Link to comment Share on other sites More sharing options...
[Ma...] Posted October 9 Share Posted October 9 From what i see in zeiss examples - they don't bother for updates. They update behaviour of api and keep old examples without modifying it. Now i wanted to test APP Configuration from Inspect 2023 - not working - after searching i found you have to use proper import of "gom.api.settings" I wonder if your approach is legit. On every example they are importing only functions "from Example.example1 import Test" - you can add "*" to import all. Would that work for you? Link to comment Share on other sites More sharing options...
[Ra...] Posted October 9 Author Share Posted October 9 The imports work perfectly fine in older versions of the script editor (2019 etc.) and they work if the app is not "Finalized". It appears that when the app is finalized it is encrypted somehow. When you run the primary script it is extracted, but the sub folders and linked files don't appear to follow through. Link to comment Share on other sites More sharing options...
[De...] Posted October 21 Share Posted October 21 I too had a similar issue & remember banging my head against the wall for a solid day. I'm not exactly sure what I did that fixed it but I tried a combination of [Switching to Absolute Imports, creating an empty __init__.py in the main scripts folder, adding the path to system path like you did (but you shouldn't have todo this) ] . since then I've had the most success by using absolute imports (eg. from Folder1.Folder2.Script1 import something) You can also try using an external folder, this always keeps the app in edit mode. hope it helps. Link to comment Share on other sites More sharing options...
[Ra...] Posted October 22 Author Share Posted October 22 The thing that worked for me was to reference the folder(s) within the APP and then the name of the routine. I have a simple routine display_it() in a script "DisplayTest.py" in a sub-folder called "test' that shows a dialog. My top level script uses: # Import the routine from test.DisplayTest import * # Call the function diplay_it() Thanks for your help everyone. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in