I created a Python script and run it as a module. At some point I needed to use pkgutil to read in a file. To be honest I didn't comment in why so I can't remember why this was necessary but I remember having a hell of a time getting it to work.
I am fairly new to the concept of python modules and the like, so I know this might be a really obvious question.
data = pkgutil.get_data(__name__, "template.json")
that works great when running it in Python python -m MyModule
But I also want to provide an executable so users don't have to install Python and all the dependencies. I've been using pyinstaller to do that but now the executable throws an error at the pkgutil line.
File "pkgutil.py", line 620, in get_data
File "importlib\util.py", line 114, in find_spec
ValueError: __main__.__spec__ is None```
Is there some way to get this to work for both cases - running it from Python and as a packaged .exe?