Python generate exe for python project - python

I am learning Python and managed to create my first project. Now I have several files and folders in my project folder which I need, to let my program (tkinter based GUI with some selenium code) run correcty.
I have not found a way to convert my main.py file to an .exe file while incuding my complete project folder.
Is there any advice which module I could use to achieve that?
Is ther a way to just pack the complete project and generate a executable "folder" which I can share with friends?

Make sure your main.py kicks off like this:
if __name__ == '__main__':
# my code
then you should be able to call pyinstaller like this:
pyinstaller main.py
If you have any data files you can add them using the command line or using a spec file. Here's the docs.

Related

Packages, modules and manim libraries

I have been using manim and manim_editor to craft some presentations for my phD (see my github https://github.com/PanoPepino and the deployments)
I would like to know how to optimise the structure of my projects, so I can have a better file organisation. What I would like to do is the following:
manim is a set of libraries that I installed making use of pip3 in the terminal. On the other hand, manim_editor requires me to specify the global path in my main.py file.
The first picture correspond to my current directory. Inside Manim_Material I have some modules (?) with all functions I have crafted over the last year. Inside Presentation_ABC folders, I have two .py files: Text.py, that contains the text I would display for each presentation and the Main_XX.py file, that contains the commands to organise each of the animations in the output file that generates the presentation.
This Main_XX.py file contains the commands you can see in the second picture.
When I try running "manim --save_sections Main_XX.py -pql" in the terminal, I get the following message (3rd Picture)
The question is: What files and/or line commands should I add to my code (in any of the files that main.py file calls) such that I can run manim with this folders configuration? I do not really understand why if I set the main.py file one level above Manim_Material, it works fine.
Thank you for your help in advance,
Panizo.
Folder set up
Code in the manim file maim
Error when running manim
I tried to used the init files inside each of both folders (Manim_Material and Presentation_ABC) but got same error.
I tried to compile main.py one level above Manim_Material (outside Presentation_ABC) and it runs without a problem.
I would like to transform Manim_Material in some sort of global library.

How can I share a multifile python project as one file

I have a python project with lots of other.py files it import from its sub folders and txt files as well
I want to share this project but only as one executable file so that Noone can see the code or the text files etc...
Is there any way to do so
If not how else can I share the project without letting anyone being able to check the code of the.py files
You can user PyInstaller (https://www.pyinstaller.org/) to build a stand-alone executable.

How to turn python project into executable when I have multiple .py files working together?

I have a python project called deduplication which works with the help of multiple scripts. As in deduplication.py makes use of readCSV.py and dbmanager.py. So how can I turn the deduplication.py into an executable if it is dependent on the other 2 .py files?
just add an .exe to your project file

How to make code ready to be made into an executable?

I created a pretty large Python project with multiple GUIs. I was thinking of creating an executable from it using py2exe, which automatically includes all packages you're using and it formats the files so that imports and everything will run fine.
However, there are lines in my code where I load the UI from a path:
self.ui = uic.loadUi('C:/peter/myfolder/stuffs/sub_ui/ManualBalanceUI.ui', self.window)
Where ManualBalanceUI.ui is the file that Qt Designer creates. I want to write it in a way that it will always open for any user. How should I change that line of code so that it will always be able to load ManualBalanceUI.ui, which is located in the sub_ui folder in the main package? Is there any way I can change the base path to something like os.getcwd(), and then do something like
self.ui = uic.loadUi(os.getcwd() + 'sub_ui/ManualBalanceUI.ui', self.window)
What would be the best way to approach this problem? Thanks
See this discussion How to make a Python script standalone executable to run without ANY dependency?.

Py2exe (Python Pygame) - Is there not an easier way?

I just checked the wiki and realized you need to input a tonne of code to change a python file containing pygame code to an exe. Is there not an easier way? Shouldn't it just be an exe file that you just open and imput what you want to change and where to save the exe to?
I am not sure I completely understand your question, but I would recommend using PyInstaller. All you have to do it go into the pyinstaller directory, and then run:
python pyinstaller.py /link/to/your/program
which should then make a directory in the pyinstaller directory named after your .py file. In that file you will have a build folder and a dist folder. The dist is the one of interest and will have your .exe in it.

Categories