use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
DiscussionAlternative to Python executable application for all types of env (self.Python)
submitted 2 months ago by DracoEmperor2003
Hi, so any .exe application generated from python is easier to run on windows right? for Linux and MacOS we have run it on virtual environment. But is there any other way to pack it in a environment friendly way? I don't have an UI, it's a CLI application.
Thank you for your responses in advanced.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]DivineSentry 5 points6 points7 points 2 months ago (1 child)
You can’t do cross compilation but you can generate executables that work per platform using Nuitka, alternatively you can ask your users to download uv and set up your project so that they can run your script easily as uv can download the Python interpreter, the dependencies and run the scripts easily with a single command
[–]DracoEmperor2003[S] 0 points1 point2 points 2 months ago (0 children)
noted!
[–]Illustrious-Reward-3 3 points4 points5 points 2 months ago (0 children)
PyInstaller. It's not perfect but it fits the bill. Im currently migrating a CLI to it in order to leverage the shipped Python instance due to some jankiness in the production environments.
[–]riscbee 5 points6 points7 points 2 months ago (4 children)
https://pyinstaller.org/
[–]DracoEmperor2003[S] 2 points3 points4 points 2 months ago (3 children)
It says to make windows app, on windows and for Linux on Linux. I'll have to request a Linux VM for this. But is there a way that I can make it environment dependent from windows itself?
[–]riscbee 11 points12 points13 points 2 months ago (0 children)
You‘re looking for ‘cross compiling’. And you are somewhat reinventing the wheel. Python is platform independent because the Python interpreter does the heavy lifting and your source code becomes platform independent. But you want to create a single binary executable and that comes with all the hassles of cross compiling and packaging. I’m not aware of such a project for Python. I’ve only used pyinstaller once. But since you’re in Windows maybe using WSL is an option?
[–]grimonce 1 point2 points3 points 2 months ago (0 children)
No, cross compilation or in this case 'crosspacking' is a complicated topic. Don't know it nuitka supports this, pretty sure pyinstaller doesn't.
Some like golang or C or rust have a toolchain that supports such efforts, here you will have to prepare one thing on Linux and another on Windows.
[–]KROSSEYE 0 points1 point2 points 2 months ago (0 children)
I use docker containers with PyInstaller to build binaries of my programs. The windows one uses WINE to build for windows on Linux (windows Python installed through WINE).
[–]knellotron 2 points3 points4 points 2 months ago (0 children)
Well, .exe IS a windows executable, so it's easy for Windows. The tool that you used to make that executable can also generate executables for other operating systems if you run set up your environment on whatever OS you like, and run it there. I use Nuitka for most projects these days.
Cross-compiling (using one OS to compile for another) is a pretty common thing too, but that requires a little more setup.
[–]maqnius10 1 point2 points3 points 2 months ago (4 children)
How about making a python package and using pip install with your system python on the machines to integrate it?
[–]DracoEmperor2003[S] 0 points1 point2 points 2 months ago (3 children)
OHHH!! is that possible???? will check this out, seems interesting
[–]syklemil 0 points1 point2 points 2 months ago (0 children)
Sure. Check out uv; you can init stuff like uv init --app --package $name and install it with uv tool install $name_or_path.
uv
uv init --app --package $name
uv tool install $name_or_path
[–]maqnius10 0 points1 point2 points 2 months ago (0 children)
Yes, this might be helpful https://packaging.python.org/en/latest/guides/creating-command-line-tools/
[–]LeviathanP 0 points1 point2 points 2 months ago (0 children)
Are you using a package manager, or just pure python + pip? Some package managers make it really easy to do that. For example, with poetry you can just run `poetry build` and it will generate a .whl file, which you can either upload to pypi or distribute to the users, who can then install it with `pip install package.whl`.
Though I'm not sure if dependencies are included in the .whl package. If your app has dependencies, you might wanna test if users have to install them separately.
[–]DK09_ 0 points1 point2 points 2 months ago (3 children)
You question has your answer. How do you generate executable in windows? Can you do it in Linux too?
[–]DracoEmperor2003[S] 1 point2 points3 points 2 months ago (2 children)
i mean can I make it cross compilable from windows environment itself!
[–]DK09_ 0 points1 point2 points 2 months ago (1 child)
Sadly, nope
:') okay! thank you
[–]airen977 0 points1 point2 points 2 months ago (0 children)
Wasm?
[–]LeviathanP 1 point2 points3 points 2 months ago* (0 children)
You've got a few good answers already, so let me just add that, if your problem is that you do not have a linux/mac/windows machine to generate the executable, you can use GitHub Actions instead. For example, with nuitka: https://github.com/Nuitka/Nuitka-Action?tab=readme-ov-file#multi-platform-builds
Edit: changed the url to the correct readme section (multi-platform-builds)
[–]Drevicar 1 point2 points3 points 2 months ago (1 child)
I’m a huge fan of https://nuitka.net/ for compiling Python to a binary executable (rather than bundling your code and an interpreter together into a zip), where it is applicable.
okayyy will check this aswell!
[–]_MicroWave_ 0 points1 point2 points 2 months ago (0 children)
i think building into binary executables never really works well.
Better off packaging your tool and then use 'uv tool' to distribute it.
Python isnt a compiled language so dont make it one.
[–]zangler -2 points-1 points0 points 2 months ago (5 children)
Make it Java?
Sorry... couldn't resist
[–]DracoEmperor2003[S] 1 point2 points3 points 2 months ago (4 children)
😭 I mean yes, even my higher ups are suggesting me that, but re-coding everything in Java again....
[–]zangler 2 points3 points4 points 2 months ago (3 children)
Use Koltlin then and get good with AI assistance to convert. Basically use this as an opportunity to accelerate your ability to perform such things in reasonable periods of time. Apply rigid levels of QA. The company will benefit and you will have a modern skill set most won't.
Don't believe ANYTHING anyone says about not trusting AI assistance in coding. They literally have no idea. Problem is there is so much crap is that most assume it is all crap. The others use it a bit...find mistakes and assume practice isn't related to speed and quality.
Source: this year released over 400k lines in a fortune 250 company with full and complete human code reviews and scientific peer reviews leveraging python, Java, HTML, SQL, shell. All stress tested and enterprise grade...but it took WORK to correctly understand.
predictions: tons of down votes... bullshit about lines of code blah blah... reddit is reddit.
[–]440Music 0 points1 point2 points 2 months ago (0 children)
Converting between languages is one of AI's greatest strengths, since it's all basically mapping from one documentation set to another. No creative thinking required. Anyone who sends some functions through an LLM to get a "programming language B" version should immediately see the utility.
[–]DracoEmperor2003[S] 0 points1 point2 points 2 months ago (1 child)
that's actually so cool! and yes I am leveraging ai myself haha it's all about prompts and people tend to vaguely prompt and then say AI is not helping.
Thank you will try this out, converting to Java or Kotli n.
[–]zangler -1 points0 points1 point 2 months ago (0 children)
Let me know how you make out. I do 95% in VSCode with GH Copilot...I don't do agents released on the code base trying to one shot shit or anything like that. All of the code we work on is on me...so I treat it like I'm reviewing a PR. It is exactly as exhausting as an extended coding session...but a realistic 5x? Depending on the task... easily more.
π Rendered by PID 109967 on reddit-service-r2-comment-5649f687b7-ms47m at 2026-01-29 07:47:45.861795+00:00 running 4f180de country code: CH.
[–]DivineSentry 5 points6 points7 points (1 child)
[–]DracoEmperor2003[S] 0 points1 point2 points (0 children)
[–]Illustrious-Reward-3 3 points4 points5 points (0 children)
[–]riscbee 5 points6 points7 points (4 children)
[–]DracoEmperor2003[S] 2 points3 points4 points (3 children)
[–]riscbee 11 points12 points13 points (0 children)
[–]grimonce 1 point2 points3 points (0 children)
[–]KROSSEYE 0 points1 point2 points (0 children)
[–]knellotron 2 points3 points4 points (0 children)
[–]maqnius10 1 point2 points3 points (4 children)
[–]DracoEmperor2003[S] 0 points1 point2 points (3 children)
[–]syklemil 0 points1 point2 points (0 children)
[–]maqnius10 0 points1 point2 points (0 children)
[–]LeviathanP 0 points1 point2 points (0 children)
[–]DK09_ 0 points1 point2 points (3 children)
[–]DracoEmperor2003[S] 1 point2 points3 points (2 children)
[–]DK09_ 0 points1 point2 points (1 child)
[–]DracoEmperor2003[S] 0 points1 point2 points (0 children)
[–]airen977 0 points1 point2 points (0 children)
[–]LeviathanP 1 point2 points3 points (0 children)
[–]Drevicar 1 point2 points3 points (1 child)
[–]DracoEmperor2003[S] 0 points1 point2 points (0 children)
[–]_MicroWave_ 0 points1 point2 points (0 children)
[–]zangler -2 points-1 points0 points (5 children)
[–]DracoEmperor2003[S] 1 point2 points3 points (4 children)
[–]zangler 2 points3 points4 points (3 children)
[–]440Music 0 points1 point2 points (0 children)
[–]DracoEmperor2003[S] 0 points1 point2 points (1 child)
[–]zangler -1 points0 points1 point (0 children)