Pyinstaller EXE Files are not independent? - python

I used pyinstaller to compile my pygame code into an exe file using this command:
pyinstaller --onefile -w gamename.py
But after moving it to a different directory and running it, it gives me file not found errors and file doesn't exist errors. ALL help is greatly appreciated. Thanks.

Possibly, you have some file locations in your code as strings. These external files are not part of your code, so they are not compiled into exe.
Check this answer about adding files in pyinstaller

Related

Im trying to turn a python file into an exe file and its not working

I tried making my python file into an exe using pyinstaller main.py --onefile --noconsole
.I was getting an error when I tried opening the exe from dist so i used --debug=all and it said pyinstaller: error: the following arguments are required: scriptname.
What exactly do i do im not too sure as its my first time.
To convert a python file to exe:
Make sure you have pyinstaller installed and up to date
pip install pyinstaller
in PowerShell type the following:
pyinstaller --onefile -w 'youfilename.py'
The file name should come out as 1.exe
Make sure are in the right directory
If you have more doubts use this link: https://www.geeksforgeeks.org/convert-python-script-to-exe-file/

Python/C API project - compile to exe

I'm working on project where I am using Python/C API and C++. C++ is used for most part of application, mainly for gui (wxWidgets), while Python is used for calculations on large data sets, e.g. from files. I'm doing it in Visual Studio and when I run the project in IDE everything works fine, like I want it to. Also, the exe file that is created during the launch of the project in the visual studio, when it is in the same folder with the python .py file, also works as it should be. But what I want to achieve is a complete application contained in one exe.
While searching for a solution, I found various possibilities to create an exe from a python file. For example, PyInstaller which I tested for a simple "hello world" python file and it works. However, I don't know and can't find a solution how to combine the exe created in visual with a python file.
In PyInstaller github issues I found that line:
pyinstaller App.py --add-data 'pathtoexe\your.exe;.' --add-binary "pathtodll\your.dll;." --onefile --noconsole --clean
And I typed this into the console:
pyinstaller myPythonFile.py --add-data 'myVisualGeneratedFile.exe;.' --onefile --noconsole --clean
But after that, when I clicked generated exe file, nothing happens.
I hope that someone has done a similar thing before and I can find help here because I'm already losing my mind on it.
According to https://pyinstaller.readthedocs.io/en/stable/usage.html, you should use --add-binary and not --add-data.

Compile python with Pyinstaller failure : Failed to execute script Myfile

After I compile myfile.py to exe with pyinstaller to one file, that file is working on my computer but not on others' computers.
error >>> Failed to execute script Myfile
I use this command
pyinstaller --onefile Myfile.py
Build your exe with --debug=all and run it in a console. Provide the output to help people help you.
Refer to https://pyinstaller.readthedocs.io/en/stable/when-things-go-wrong.html#getting-debug-messages to get more details if needed

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: Can't find .so module when exe is executed

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.

Categories