DEV Community

Discussion on: How to convert .py to .exe? Step by step guide.

Collapse
 
eshleron profile image
Eshleron

Hi!
Don't pack it into .exe file. Leave it outside .exe. It should work that way.

Collapse
 
r4nta profile image
r4nta

Thanks for your quick response!

How can I leave the config.py file outside? I feel that PyInstaller loads the config.py file, compiles it into the exe and then has this fixed state in the program. I need to be able to modify the config file, after compiling.

How do I instruct PyInstaller to leave the config.py file separate?

Thread Thread
 
eshleron profile image
Eshleron

You are right about fixed state. What PyInstaller remembers is the name of the file. So if you paste the same file with different content(some .txt maybe) it will work with it just fine because it thinks it is the same file.

Thread Thread
 
r4nta profile image
r4nta

That would be amazing and a super easy solve. Problem: I cannot find the config.py in the folder that was created by PyInstaller. Actually I can't find any of the modules I import. Are they merged into the .exe file?

Thread Thread
 
eshleron profile image
Eshleron

You should add files manually sometimes. Try copying config there. It should work.

Thread Thread
 
r4nta profile image
r4nta

It does not work. When I manually add the config.py, the file is added - yes. But when I change variables in the file, nothing changes in the program. The .exe does not load data from the config.py

Thread Thread
 
eshleron profile image
Eshleron

Make sure you added the fie to Auto PY to EXE additional files menu for it to be compilated with .exe.

Thread Thread
 
r4nta profile image
r4nta

I changed my config file to .json and now it works. Even with adding the file manually, it does NOT work when the file is .py (the file was in the folder, but changing settings did not reflect in the script).

Thread Thread
 
qwerty_plm profile image
SwethaVSarma

Can you please suggest on how to do this? I have converted the python codes to exe using pyinstaller. I kept the input python file wthout converting to .exe so that the main exe can read from it. But when i change the values in the input python file I have to again use pyinstaller and do the convertion of main python file.

Some comments have been hidden by the post's author - find out more