PyInstaller: Can't find .so module when exe is executed - python

A python script uses a .so file.
I made an exe for this python script using PyInstaller.
But when I execute the generated exe, it is unable to locate this .so file
So how to link this .so to a python code that will get converted to a .exe
Note: when running the .py program, if I set the location of .so in LD_LIBRARY_PATH, it executes the program correctly but once I make the exe using
pyinstaller script.py --onefile
(with .so in the same directory), it doesnt find the .so file..
Thank you in advance

You need to make sure that your . so file is in your system library path as well as your python library path. Setting your LD path is a quick fix. PyInstaller will need it in your system path. Depending on your Windows version it's Environment variables>PATH.

Related

How to create exe of project who has .cxx .py file and many dlls

I have a code who is depended on Qt, PyQt, VTK, ITK, libs.
using CMAKE to build
Environment : Windows
I want to distribute EXE who has cxx, py files and related dlls
I have tried to compile and got executable but my python files are remaining necked.
I don't want to share python files as a script.
how we can make those python files as a dlls
python is often a hard language to turn to exe but the best way to do so is using the pyinstaller package. Installed by pip install pyinstaller and can turn a .py file to a .exe by pyinstaller --onefile FILENAME.py in CMD. After that your exe file should be stored in a folder called disk. The other files can just be included in the same file as the exe.
docs: https://pyinstaller.org/en/stable/

Python create exe file error

I'm trying to create a exe file from my .py file but using both, PYINSTALLER and PY2EXE gives me a strange error:
The google.py file that I'm tying to create EXE existis in the requested directory and both PYINSTALLER and PY2EXE are correctlly installed.
Does anyone know the root cause of the issue? How could I create a exe file from a .PY?
As I know you must use argument --onefile Without it the libraries will be distributed as separate file along with the executable.
Here is exaple:
pyinstaller --onefile script.py

PyInstaller 3.3.dev0+1804636 does not exclude source code in exe

i just compiled my main.py using PyInstaller 3.3.dev0+1804636 and Python 2.7.10 and i realised that the .py is included in the .exe. How do i tell PyInstaller to exclude the .py files and only use the .pyc ? It seems to me that PyInstaller needs the .py to look for dependencies, etc. but it somehow includes the .py together with the .exe even though the PyInstaller documentation says that it hides Source Code from the bundle.

File resources in Python

I got few images and one exe file which I would like to bundle inside of the python exe file?
I mean the same or similar way that it could be done in the visual studio:
Please tell me if its possible, if so , how could I access the resources then?
I am using pyinstaller if it does matter.
You can't bundle your resources inside .Net runtime. Visual Studio allows you to bundle your resources inside your project exe not inside .net executable.
Same way you cannot bundle resources like images and exe files inside python.exe but using Pyinstaller you can create your project exe which will include your resources.
To create a single file use --onefile flag while bundling your project. As per Pyinstaller documentation -
"In a --onefile distribution, data files are bundled within the executable and then at runtime extracted into the work directory."
Here is a link for how onefile mode works

Do I need Python installed if I have PYC files?

I want to add Python as a scripting language to my game. If instead of distributing PY script, I distribute the PYC compiled files with my game, will the user still need Python installed, or will the DLL be sufficient?
Not only would they still need the Python interpreter, but the compiled python byte-code files are not guaranteed to work across different platforms.
You do need an executable to actually load the files into the VM. Fortunately it doesn't need to be very complex.
pyinstaller can be used to convert the .py file into an executable file
to install the pyinstaller
pip install pyinstaller
and to convert the .py file let's say file.py
pyinstaller file.py
this will make two new folders in the same directory
build and dist. dist folder contains all the required dll and file.exe to run the python code without python installed.

Categories