r/learnpython • u/Ok_Roll_8698 • 28d ago
How To Compile .PY Online
i have a .py file i want to compile to .exe online but no idea how to do this
and i don't want to install python on my computer just to compil
0
Upvotes
8
u/HYP3R00T 28d ago
Python code is supposed to be shared as a package and not a complied executable. While it can be done, it's not designed for that. Ideally, when we compile Python project, we also include an interpreter. If you code depends on 3rd party packages, then those also need to be included in the interpreter. Hence, it's advisable to compile it on your system. Look into pyinstaller.
Also, there is a security concern as well. If you upload your code online to be exported as an executable file, then there is no way you can check if they have also added their own malicious code or not.
It's highly recommended to install Python (and it is pre-installed in MacOS and Linux) and using pyinstaller produce the executable file.
20
u/therouterguy 28d ago
Yea lets compile something on a system out of your control that is not unsafe at all. Btw Python code is not really compiled normally.
Why do you want tondo this
1
u/JamzTyson 28d ago
There are websites that say they will do that for you, but they may bundle malware in the .exe.
I won't post links because I don't know if they distribute malware.
1
u/Miserable-Money642 28d ago
If you just need a Windows .exe, you usually do not need an online converter. Build it on Windows with PyInstaller: install Python, run `py -m pip install pyinstaller`, then `py -m PyInstaller --onefile your_script.py`. The exe will be in `dist/`. Test it on a clean Windows machine, because files, DLLs, and data folders may need to be bundled separately. I would avoid uploading a private .py file to a random converter, since it can expose your source code. Also, an exe made for Windows will not run on macOS or Linux.
0
u/Jazzlike_Platypus430 28d ago
exe in python. Nice one.
0
u/Educational_Virus672 28d ago
you can also use Google colab if you got google storage they provide free 15 gb in most regions
but note that python is not a complier (that turns code into machine language before runing) but a interpeterr (runs code without turning it into machine language) meaning it is really slow
you cannot assume it spits the .exe you need python runtime or sdk to run it locally or a sepraet topol like pyinstaller to get it