How to convert .py file into standalone exe file for python3.6, please explain with examples
Please explain it with some examples to make setup.py file, so that I can execute any text file called in python script and save the output in csv file by calling the csv file.
Related
I have a python code that is taking some info from a website by selenium and then write them into a json file, after I created an '.exe' file by pyinstaller and run it I don't know where this json file is saved.
Where could be saved, should be in the initial directory?
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
[ I used translator ]
I want to get the name of the exe file made from Pyinstaller.
I tried os.path.basename(__file__) , but i returned python file's name(before using Pyinstaller).
I am sorry for my English and thank you
os.path.basename(sys.executable)
Using pyinstaller to create .exe file, it will create the .exe file with the source code file name(ex- demo.py will produce demo.exe file at the output destination) if using --onefile and if you're using --onedir the .exe file will be stored with the same name as in --onefile but inside a folder with the same name, so the directory will be as follows: output_destination/demo/demo.exe
How do I package files into an EXE file that is generated via PyInstaller --onedir?
I see, that I can add the file with
a.zipped_data+=["version.json", "version.json", "DATA]
PYZ(a.pure, a.zipped_data)
pyi-archive_viewer shows the file in PYZ-00.pyz
But
pkg_util.find_loader("testmod").get_data("version.json")
does not find the file.
NB: I can't use --onefile mode, because it would need to unpack several 100 MB at each program start. And I want to tie several files (not only the version file) with the executable.
The name passed to get_data was wrong.
For an Windows executable c:\test\testpgm.exe the correct name would be c:\test\version.json
In Linux the executable might be /usr/local/bin/test/testpgm and the correct name would be /usr/local/test/version.json
I am using iexpress to make my .jar files into .exe files
for this I add the jar file(myjarfile.jar) and in run command box I type : java -jar myjarfile.jar
but after creating the .exe the cmd that is flashing says cannot find the jar file myjarfile.jar
can any body help me find what I am doing wrong
To test this, I built a simple HelloWorld.jar file (using these instructions) and tested it like so:
java -jar HelloWorld.jar
Then I made an IExpress package with it. The Install program was exactly the command I used above. This worked exactly as it should.
Two possible causes of the error:
In the IExpress wizard, there's a checkbox Store files using Long File Name inside Package. You should definitely select this option; ignore the warning that appears, as it applies to Windows 95/98. In the .sed file, this is:
UseLongFileName=1
Check that the .exe actually contains myjarfile.jar. 7-Zip will open the .exe and show you the archive contents. (IExpress .exe files are just a CAB file with a wrapper.) If the file is missing, then you'll need to check your .sed file to see what went wrong.