I would like to create an executable file from my python project that consists of one python file that uses gecodriver.exe, I have tried using pyinstaller for this matter, however the program closes as soon as it opens, basically it doesn't work. I suspect that the .exe file that is created by pyinstaller does not include or cannot see geckodriver. Any sugestions how to make it work will be helpful.
Related
I Created a Program That Has 2 .py files.
I Want To Make The Program a .exe file, I do it using cx_Freeze.
My Problem Is That I Convert The main.py To .exe but The Second Python File Is Still a .py File.
I Don't Want It Be a .py Because If It Is The User Can See The Code.
If I Also Convert The Second Python File The Program Doesn't Work Because I import The Python File In The Main File.
Any Suggestions?
(I Don't Want To Copy The Second Python File To The Main Python File)
You are chasing the wrong rabbit here. The various tools that generate executable files from Python code are not compilers. They are just tools that embed a Python interpretor with py (or pyc) files to allow users to use the program without a prior Python installation.
Said differently you should not use them to hide your code (except from people not knowing a lot of Python): a pyc does not contain text code but according to the answers to Is it possible to decompile a compiled .pyc file into a .py file? , tools exists that convert back a pyc file into a py file (of course except the comments).
IMHO, you should better google for python obfuscate to find tools dedicated to obfuscation, what neither cx-freeze nor pyinstaller are.
BTW while there are appropriate use cases for obfuscation you should be aware that a determinate attacker can always circumvent it. The reason why the real protection for intellectual property is law and not technics...
I'm not sure how two or more .py files can be converted to .exe.
But in python the easiest way to convert to .exe is a module named pyinstaller .
You can install it using command pip install pyinstaller can get it . After just go to the directory where your project files are and open command prompt in that directory and execute pyinstaller file_name
I am trying to turn a .py file into .exe so that it's runnable on other computers without python. I followed this tutorial, installed pyinstaller then ran the command pyinstaller --onefile IRV.py without the -w since my program runs in the console. It successfully built the .exe file but when I run it it immediately closes even though the program itself asks for input at the beginning. It uses a bunch of .txt and .xslx files from the folder of the .py file so I dragged the .exe out of the dist folder but it still gives the same error. I managed to make a quick print screen before it closes and it gives me this error: https://imgur.com/a/w7TVjaN
The script doesn't even work if I double click the .py file. However it runs perfectly fine if I open up the .py file in an IDE like Spyder. When I run the .exe file it opens up the cmd for a few seconds with nothing written on it and then quickly writes that error I managed to screenshot and then closes. If I double click the .py though it instantly closes without the wait or the error message.
Pyinstaller didn't find the libraries or modules you imported. In the build folder that was deleted in the tutorial, there's a text document that shows warnings for libraries that aren't found by the pyinstaller. You may need to check that.
This Q&A mentioned a problem that is related to your Question: No module error when running python script from command prompt
I have a program that makes use of the MultiListView from TkTreeCtrl which I'm trying to compile into an executable file using pyinstaller. I'm able to create the executable file and run it, however as soon as it gets to the initialization of the MultiListView it throws up a window that says "Failed to execute script app". How can I get pyinstaller to recognize MultiListView? TkTreeCtrl is unable to be installed via pip, it required putting the folder in my directory and running setup.py.
I've tried searching for a "hook" file online to allow pyinstaller to find the module, I can't seem to find one. I've also tried --hidden-import=tkinter as I've seen that suggested but can't decipher what it's supposed to do. It does the same thing with or without being compiled as a single file. I used a logger and guaranteed that it's on the line where the MultiListBox is created that the program crashes. If it needs stating, I can launch the python file using the command line just fine on my computer.
I use pyinstaller --onefile --windowed Scripts/JobMaintainer/app.py in Command Line to compile the program
Expected: A Google search would result in a hook file that I could attach to my pyinstall which would allow TkTreeCtrl to be added to my executable file
Actual: Until I find some sort of solution, TkTreeCtrl causes it to be impossible to create an executable file from a python script.
I wrote a program in Python that includes external files, including images and a GUI .ui file.
I want to convert the Python script to a single executable (.exe) file using PyInstaller. When I try to open the .exe file, the program does not open.
You will need more information on why the application is closing immediately in order to solve your problem. To view the error messages associated with running your executable, run the .exe file from the command prompt: /path/to/app/dist/MyApp.exe. This will allow you to observe any errors that may exist after the app was bundled. If the program fails during an import statement, you may need to add a package to the hiddenimports list in the .spec file. Check the PyInstaller documentation for instructions on modifying the .spec file.
I want to create a .bat file to run my .py file on Windows without Python installed, mainly so I can send my programs to friends. So in my .bat file I would like to:
Change to the current working directory. (So it runs wherever the file is)
Change directory to a folder inside that directory.
Run a python file without my friends having to install python themselves.
Run a .py file without Python installed using .bat
You can't run a Python script using a batch command without Python being installed. You can compile an executable with Py2exe (which bundles an entire Python interpreter with your script), or convert a subset of Python to C++ with shedskin, which can then be compiled to an executable. You could also issue a shell command to install Python if it's not already installed and the user has internet.
But doing exactly what you asked is impossible.
Take a look at http://www.py2exe.org/ which will convert you python code to a executable windows program that you can send to your friends.