Pyinstaller packages the exe file and reports an error when running: FileNotFoundError: [Errno 2] No such file or directory xxx.txt

Use pyinstaller to package the .py file, execute the generated .exe and report an error, as shown in the following figure:

Insert picture description here
Reason: The .py file uses a relative path, but the generated .exe is in the dist directory, so the execution error occurs.

Solution: Change the relative path to an absolute path and repackage. OK!

Guess you like

Origin blog.csdn.net/weixin_47542175/article/details/114194954