It's a bad idea to do this: pyinstaller is meant for packaging and distribution, not for development. Packaged file aren't meant to be changed. If part of the program is modified, you should release a new version of the whole package. If you would like to do runtime configuration, then you should use a configuration file, rather than changing the program.
However, if you insist on doing it, you could use the --exclude-module
flag. Run
pyinstaller --exclude-module b main.py
so that b
is not bundled with main. If you try to run the bundled package now, a ModuleNotFoundError: No module named 'b'
would show. Copy b.py
to the directory (dist/main
), run main
, and everything would work again. Now you could change b.py
, and the difference would show during the execution.