When creating an exe file with pyinstaller, how to include text files together

Asked 1 years ago, Updated 1 years ago, 73 views

import shutil
import os
import time

def do():
    filename = 'GameUserSettings.ini'
    username = os.getenv('USERNAME')
    #dir = 'C:\\Users\\' + username + '\\AppData\\Local\\'
    dir = 'C:\\Users\\' + username + '\\AppData\\Local\\TslGame\\Saved\\Config\\WindowsNoEditor\\'
    shutil.copy2('aaa.txt', dir + filename)
    #Copy default setting values


print("If the application is not completed and turned off, it is not applied.")
time.sleep(1)
do()
print ("Applied")
time.sleep(1)

When enabled, GameUserSettings for a specific path.I'd like to make a program called ini The data value of the file is stored in aaa.txt.

That is to operate normally in quite the same when we make pie

directory. I'd like to use a computer and create files to exe pyinstaller aaa gesseoseo ... don't know how to merge with a file, txt I have a question.

When I searched about pyinstaller, they told me to use add-data.

pyinstaller -F --add-data="aaa.txt;data_files" file.py

If you run it on the terminal like this, it says success, but if you run the exe file, it says an error that aaa.txt is missing. ㅠ<

pyinstaller exe txt shutil

2022-09-22 15:10

1 Answers

There's a kind example code in the stack overflow.


2022-09-22 15:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.