There are some flexible parts when executing the file, so I made the code as below
# private_lib.py
filepath = r'C:\Users\Desktop\test'
# main file
from private_libimport filepath #import personal library
import importlib
while file := os.listdir(filepath):
try:
importlib.reload(private_lib)
# Attempted to change the filepath in private_lib.py to match the installation computer environment
# The following is omitted
Whenever I changed the contents in private_lib.py in the editor, it was well applied to the main file, but since I made it with pyinstaller, the contents were fixed when I made it for the first time.
Come to think of it, when creating an executable file with pyinstaller, the internal value of the library seems to be fixed to the value at that time. The code in the executable will continue to reload private_lib, but it seems that putting the changed private_lib.py in the filepath folder does not bring it up.
Previously, I did this process in json file, but it was better to do it in Python file, so I'm looking for a way, is there a solution? In the above example, private_lib is written only as a folder path, but various settings such as a phrase expression form are included.
python pyinstaller import library
I'm sorry, but I think it's the right way to put the settings in json.
© 2024 OneMinuteCode. All rights reserved.