Pyinstaller 3.4
Python 3.7 (Windows 7)
I have a use-case where my main python script, foo.py
, generates a traylist.py
file that I want to import stuff from.
foo.py
occasionally has to update this traylist.py
file. Therefore, there is a need for foo.py
to be able to import that traylist.py
again in a function. I accomplish this using a reload module function like this:
import traylist
importlib.reload(traylist)
menu_def = traylist.menu_def
I have also tried the following code with the same results (works within interpreter but fails when run as .exe)
import traylist
del sys.modules['traylist']
import traylist
menu_def = traylist.menu_def
All this works when running foo.py
within the normal interpreter (python foo.py
). However, when I create a --onefile
.exe using pyinstaller, the values in the traylist module never refresh. I've checked the paths using sys._MEIPASS and can see the new file generated in the MEIxxx folder. I just can't get the .exe to reload that module correctly.