Creating an .exe file when I have multiple .py scripts - python

I want to create an exe file off of my main python script, a GUI using PyQt5. I have used pyinstaller before, and it has worked fair enough when I had a single .py script. But this time my main script calls other scripts I have written (there is a General Class which has children in different scripts, and the main script creates instances of the children and then calls appropriate functions from the children or parent class depending on the buttons the user clicks)
Can pyinstaller handle that, and if so, how?
Thank you very much
I have tried PyInstaller before, but only for a single file. For multiple files I really have no clue.

I think this is very similar to your question:
Pyinstaller module issues
Please read the post and the answer and adapt it to your problem. Should work. If not, plz add error messages etc.

Related

How can I execute .py script in Bitbucket pipeline?

I have a .py script for removing unused tags after certain time, but I want it to be executable in Bitbucket pipeline. It will also be nice if someone can explain a bit more the thing with 'images' (Python Docker images)., which one should I use, why, etc.
Roughly, the main thing that I want to do in pipe is:
fetch all
execute the script
move it to certain .txt file
Let's say that I know the way how to do first and last thing, but the main question is executing .py script. I'm not even sure how to start.

wxpython GUI program to exe using py2exe

I am new to python programming and development. After much self study through online tutorials I have been able to make a GUI with wxpython. This GUI interacts with a access database in my computer to load list of teams and employees into the comboboxes.
Now my first question is while converting the whole program into a windows exe file can I also include the .accdb file with it...as in I only need to send the exe file to the users and not the database..if yes how.
My second question is... I actually tried converting the program into exe using the py2exe (excluding the database...am not sure how to do that) and I got the .exe file of my program into the "Dist" folder. But when I double click it to run it a black screen (cmd) appears for less than a second and disappears. Please help me understand the above issue and resolve it.
am not sure if I have a option of attaching files...then I could have attached my wxpython program for reference.
Thanks in advance.
Regards,
Premanshu
The console could possibly appear if you used the 'console' parameter to setup(). Switch to 'windows' instead if that is the case. Can't say for sure without seeing your setup.py script. Possibly your app could also be opening console, but again hard to say without seeing source. One thing to check is to make sure you are not printing anything to stdout or stderr. You might want to redirect all of stdout and stderr to your log just in case, and do this right at the top of your start script so that if some 3rd party import was writing to stdout you'd be able to capture that.
The db is not part of your executable, so py2exe will not do anything with it. However, you should probably package your application with an installer, and you can make the installer include the db and install it along with the executable.

How to turn Python program into executable file

I apologize for such a basic question. I've done some research online and still cannot figure out for the life of me how to turn a python folder into something like an actual app I can open in OS X. I am using Mac OS X, Terminal and Coderunner for my Python project.
Here are a few options:
Platypus is not Python-specific. It lets you wrap a simple GUI around a command line tool.
py2app is Python-specific and a good choice if you have a GUI, or need to run in the background.
PyInstaller is similar to py2app but cross-platform; I've never used it, so I don't know how well it works.
The right choice depends on what your program does; who is the expected audience — do you need to redistribute it, if so how, and so forth. If you want to make the application entirely self-contained — not dependent on anything else beyond the OS — then things get more complicated (though certainly not insoluble; there are several commercial Mac desktop apps written in Python.)
Typically you would make the script executable by putting
#!/usr/bin/env python
as the first line, and then in a terminal window typing
chmod u+x myscript.py
You might also want to put it in a special scripts folder and then add that to your PATH by editing .bash_profile. (I am putting a lot of buzz-words here to help you find the tutorials explaining how these things work.)
You can wrap your script into an Automator object if you want to try running it that way, but in the long run you will be better off getting comfortable working in a terminal window.
It would also help to know what your app does: Process files, generate a GUI, do a calculation, etc...

Issues with pyinstaller

I have created a working GUI program (using tkinter), but when I try to compile it using pyinstaller (py2exe only works for python 2.6 and I used 2.7 for the program), it doesn't work. I have 2 files: program.py, and data.xml. The program uses the xml document to retrieve information and display it to the window. I have looked all over, but no one seems to have had a similar problem, and the pyinstaller documentation is useless. the command I used was
python pyinstaller.py -w -mdata.xml -nProgram program.py
It appears to make the spec file fine, but generates an error with a large traceback upon build:
pyinstaller.utils.winmanifest.invalidManifestError: Invalid root element <items> - has to be one of <assembly>, <assemblyBinding>, <configuration>, <dependentAssembly>
and quits the build process. This is the first time I have tried to build an executable for a project, so I'm kind of shooting in the dark here. Did I forget to do something, or did I just find a bug in pyinstaller's program?
Normally I wouldn't answer my own question, but I have solved the issue and I think others should know about this. When creating your program and using an xml with it, you must have the root tag (the first one) as <assembly>. Not sure why, but it works when I do that. also, don't forget to use the --hidden-import=Module command if you imported anything into your program.

How to pass multiple arguments to a python program via windows right-click context menu

I have a python program which is converted to a windows exe using py2exe. I have also added it to the windows context menu. Basically when one right-clicks on any file another option appears with a link to my exe.
The problem is, when I select multiple files, multiple instances of my program starts up.
Is there any way to pass multiple arguments to the exe?
Thanks,
Sreedhar.
If you add that that exe to windows context menu manually, then you did the hard step manually. What are you looking for is ability for py2exe to handle the Windows Shell Context Menu, that is not a trivial step and I doubt if it is possible using py2exe itself as I could find no references to in the docs or in the internet.

Categories

Resources