PyInstaller

PyInstaller usage guide

Compile

pyinstaller --onefile --add-data "file1.txt;." --add-data "file2.txt;." script.py

If reading a file:

instead of:

with open('foo/bar', 'r') as f:
    ...

use:

path = 'foo/bar'
if getattr(sys, 'frozen', False):
    path = os.path.join(sys._MEIPASS, path)
with open(path, 'r') as f:
    ...
Content Licensed under CC BY-SA 4.0. Code licensed under the MIT License.