cdfarrow / flextools

Python scripting utility for SIL FieldWorks Language Explorer (FLEx)
Other
15 stars 5 forks source link

FlexTools doesn't run with Python 3.11 (importlib error) #42

Closed canilcomputer closed 5 months ago

canilcomputer commented 5 months ago

Running FlexTools gives the following error:

Traceback (most recent call last): File "F:\FlexTools\scripts\RunFlexTools.py", line 9, in flextoolslib.main(Title) File "P:\Python311\Lib\site-packages\flextoolslib\code\FLExTools.py", line 135, in main mainForm = FTMainForm(appTitle, customMenu, statusbarCallback) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "P:\Python311\Lib\site-packages\flextoolslib\code\UIMain.py", line 612, in init self.LoadModules() File "P:\Python311\Lib\site-packages\flextoolslib\code\UIMain.py", line 521, in LoadModules errorList = self.moduleManager.LoadAll() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "P:\Python311\Lib\site-packages\flextoolslib\code\FTModules.py", line 146, in LoadAll module = self.importModule(moduleName, moduleFullPath) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "P:\Python311\Lib\site-packages\flextoolslib\code\FTModules.py", line 52, in importModule spec = importlib.util.spec_from_file_location(moduleName, modulePath) ^^^^^^^^^^^^^^ AttributeError: module 'importlib' has no attribute 'util'

Adding import importlib.util to FTModules.py fixes the problem.

cdfarrow commented 5 months ago

Thanks for supplying the fix. I ran into this yesterday, but couldn't figure it out and the problem went away. It seems it was fragile (depended on other things importing importlib.util) (See https://discuss.python.org/t/python3-11-importlib-no-longer-exposes-util/25641)