Not understanding the path of files in Python exe output

Viewed 112

my Python project works in editor. I get .exe output from Python (.py) program. The .exe file could not understand the path of the files.

import os
a = os.getcwd() + "\\Logs\\" # Find the log directory

# Read the text in the Paths.txt file inside the logs directory
b = open (a + "Paths.txt", "r").read() 

When the code is executed in the editor, the text inside the file is read and the file path is understood. But when executing the .exe file, the program can not detect the path of the log file.

Log file path at runtime (in editor or .py): currect and understood
'C:\\Users\\mohammad\\Desktop\\projects\\Logs\\Paths.txt'
Log file path at runtime (in .exe file): not currect
'C:\\Users\\mohammad\\Desktop\\projects\\dist\\Logs\\Paths.txt'

I tried some methods such as short route but it did not work.

Also, due to my problems, I output Python file as follows:

pyinstaller.exe --onefile --add-binary "C:\\Users\\mohammad\\Desktop\\projects\\pythoncom310.dll\\;." Start.py

And i'm using version 3.9 of Python and the VScode editor. Thanks for your time

0 Answers
Related