Pyinstaller adddata query - python-3.x

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.

Related

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.

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

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

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

Why does my pyinstaller created executable require admin privileges?

I've written a Python program which I distribute using pyinstaller. I've been using the onefile option so far to create a standalone executable. That's been great up until now, but as the application has grown the startup time is getting a bit long. I'd also like users to install the application properly to make upgrading simpler.
I've been trying to create a single directory version of the app using pyinstaller's onedir option. However, the resulting .exe file that is created requires admin privileges to run, which the onefile version did not. The program itself doesn't need any such privileges so I assume this is something that pyinstaller is doing. How do I create an application that doesn't require admin privileges?
Additional info:
Python 2.6, pyinstaller v1.4
Application uses PyQt4 and pygame modules.
Trying to create executable for Windows 7.
Using -w pyinstaller option to create a windowless executable.
admin privileges could be asked in few cases:
A. if the executable name contains relevant keywords (like setup, install, update or patch)
B. the application requests it in it's manifest.
C. the .exe file name do not match the name in the manifest file.
if you create a .spec file for your application package, you can add
exe = EXE(
...
manifest=None,
...
)
and it won't ask for password, unless you rename it to setup or install.
I have recently run into this issue, and my experience in solving it was thus:
PyInstaller with --onefile option creates a manifest file in the 'executable'. This manifest file on Windows tells the OS a few things about the application it is bundled with. One of the things it specifies, is the application name/manifest file. The format of the manifest filename is appname.exe.manifest. If your program is frozen with PyInstaller, the executable name that it stores in the manifest will be the name given to the completed EXE under the /dist folder of PyInstaller. IF you rename the EXE, the manifest file packed with it is no longer matching! Therefore, create a manifest file with the same name as the final EXE filename and run PyInstaller with the --manifest option, OR don't rename the EXE that PyInstaller creates.
When you package the PyInstaller project with the custom --manifest, the renamed program no longer requests administrator elevation.

Resources