How to embed a conf file along with python script into my .exe file - python-3.x

I am trying to create a .exe file from my existing pyhton script and it's conf file. The conf file contains sensitive information and hence can't be distributed outside of the binary.
So the requirement is:
as per this image

First thing PyInstaller does is to build a spec.
That file is stored in the --specpath= directory, by default the current directory.
You can add binary files to the bundle by using the --add-binary command option, or by adding them as a list to the spec file
a = Analysis(...
binaries=[ ( '/usr/lib/libiodbc.2.dylib', '.' ) ],
...)
or directly in the console
pyinstaller --add-binary '/usr/lib/libiodbc.2.dylib:.' myscript.py
See this

Related

How to convert all nodejs files into one executable file

Currently, I'm using pkg module to convert it to a single exe file and it does only one main.js file, but on the root folder, it has multiple *.js files that are needed to run along with this. I want all packages and files to be executed with a single click without exposing the files or installing them on the machine.

getting a spec file instead of a exe with pyinstaller [duplicate]

I am completely new to python and trying to create an application (or .exe) file for python using pyinstaller. I ran the command pyinstaller -[DIRECTORY].py and it saved it to an output directory "C:\Windows\System32\Dist\Foo", however when i tried to locate the directory it did not seem to exist (Dist).
NOTE: i'm trying to convert a .py file to .exe file in Python 3.5
Thanks for any help :)
If you set your command directory to the .py script location and run pyinstaller yourscript.py, it will generate folders in the same location as your script. The folder named dist/ will contain the .exe file.
Could you please try easily the command:
`pyinstaller yourscript.py`
You will get your output folder anyway if everything is correct with your software/module.
Second you can have no rights into System32 folder, so you could try a different folder.
Third you might have inconsistency with the path \ or /.
Hope those three suggestions will lead you to the correct solution :-)
Have a nice day.

Hide input files during the conversion of python scripts into exe

I have python scripts in folder A and some dependent input files (.xlsx,.txt) in folder B.
I am using cx_Freeze to convert them into exe.
I have the files in the folder B as a list in include_files in setup.py
During the conversion, the files fall in the build folder.
The files should not be visible to the user, or at least they should be only in read-only mode.
You can use os.chmod at the end of your setup script to make any file of the build directory read-only. For example:
import os
import stat
os.chmod(path_to_file, stat.S_IREAD)
Of course you need to know the path to the build directory. You can also tell cx_Freeze which directory to use as build directory by using the build_exe option of the build_execommand, see the cx_Freeze documentation.

Pyinstaller adddata query

When I am trying to converting my python file into executable and binding with pdf with using command add-data. My pdf file is store no where due to this I cannot open my pdf file while opening executable.(yes, but command will create executable properly but there storing of pdf in default temp directory).
command:
pyinstaller.exe --add-data src;. --onefile python_file.py
P.s:- I tried to popen my file through my code but pdf is storing nowhere so, I cannot execute popen command
The documentation of pyinstaller is here: https://pyinstaller.readthedocs.io/en/stable/usage.html
and syntax of this command is:
--add-data <SRC;DEST or SRC:DEST>
Additional non-binary files or folders to be added to the executable. The path
separator is platform specific, os.pathsep (which is ; on Windows and : on most unix
systems) is used. This option can be used multiple times.
It means that for each folder of data you need use this parameter once. SRC is path in your system. DST is path relative to your bundle root. I suggest do not use --onefile when you have some problem with build. Then you can easier inspect resulted build.

How to include all necessary files and folders in python executable file using pyinstaller on ubuntu?

I want to keep all the python script files hidden and want to give executable file to the user.
Here's the screeenshot of the folder:
I am running it from the webroot directory of a project.I am going to run my project on the local host. In the Al3ViewerController I have given path to the main.py/ exe main file using shell_exec. But I need to keep the folder containing all the other python and DB files and I cannot do that for code security purpose, hence an exe file to run. could be --onefile / folder. I would want to remove that folder completely and just run from the executable file

Resources