r/Python • u/apo383 • Jan 01 '25
Discussion Python Golf: How few installations/versions do you have?
My New Year's resolution is to cut down on Python installations and versions. Only a year ago I purged and got down to three. Recently looked at available kernels in VS Code, already at NINE! It's still three installations, but there are many Python versions scattered across various environments. There are no weird packages and no need to be cutting edge, so probably all could run on just 3.12 or so.
So, how few installations AND versions can you work with? Looking for a simple management procedure, to combine multiple environments or standardize several on a minimal number of versions.
(My installations are miniforge, homebrew, and Mac system. Miniforge intentional, but never wanted so many versions. Homebrew there cuz some brews want it. System largely unused but can't delete. At least no Python 2!)
EDIT: Thanks for the advice! I've gotten rid of my old miniforge installs and now have a single python 3.13 on homebrew. Switched to uv to manage environments. I have yet to migrate old mamba environments over, but I'm fairly confident that they will all or mostly be fine on that single 3.13. Reclaimed 20GB from the clean-up! I am thankful for the original Anaconda, which really tamed a wild west of installs, followed by Miniforge/Mamba, until these more recent ways to manage dependencies.
6
u/Helpful_Home_8531 Jan 02 '25
You're solving the wrong problem. Get a better system for managing your installs and use one per project.
you have many options for doing this, conda, pyenv, nix, docker, uv, asdf, the list goes on.
2
u/apo383 Jan 02 '25
I believe you. I just dumped all my miniforge versions and am trying to standardize on one homebrew 3.12 and uv for packages. Then slowly try to get vs code to know about it.
2
Jan 03 '25
When vscode asks you to set interpreter path, you just link it the one in .venv
Also if you create .python-version file, and write the version then then uv will automatically use that version of python when running code in that project (if you specify a version that you don't have installed, it will install that version for you without messing up global installs)
5
u/mestia Jan 01 '25
Nobody knows, its also by design: https://xkcd.com/1987/
2
0
2
u/drknow42 Jan 01 '25
I only have one version of python on my system and all my venvs exist in a central location. I added an alias that allows for ‘pyvenv envToActivate’ to quickly switch between the environments.
One installation, one version, always targeting LTS.
Bleeding edge is for entertainment, not production, imo.
1
u/apo383 Jan 01 '25
That sounds amazing. What do you do with central environments when you want to share a git repo? Do you export a requirements.txt to the local directory, or is there another way?
1
u/drknow42 Jan 02 '25
Basically, sharing environments is still manual because I don't really do it that often. Requirements.txt became more powerful once I designated a specific home for pyvenvs (for me it is `D:\pyvenvs\`) and created the *scripts* (to correct myself from earlier).
They are plain and simple scripts with hardcoded paths because I was simply tired of switching between virtual environments in such a verbose way.
I eventually want to stop being lazy and make it so `pyvenv create <venv_name>` and `pyvenv load <venv_name>` just works, but here is the batch and powershell versions:
Batch:
@Echo off D:\pyvenvs\%1\Scripts\Activate.batPowershell:
if ( $args.Count -eq 0) { Get-ChildItem "D:\\pyvenvs" -directory | Select-Object Name | Out-Host } if ( $args.Count -eq 1) { $pyvenv = $args[0] & "D:\pyvenvs\$pyvenv\Scripts\Activate.ps1" }Edit: The powershell script is more useful, as
pyvenvwith no arguments produces a list of environments.
2
u/robberviet Jan 02 '25
Around 30. Each project has one. Oh you mean python, not venv. Then from 3.9 to 3.13. I have projects for years, no need to upgrade them.
I use mise with uv btw. Used to use rye but no need.
1
2
u/cointoss3 Jan 02 '25
Check out uv and quit thinking about python versions or environments. Now on a new machine, I just install uv. I don’t install a python binary directly and I ‘uv run’ scripts. Even 1-off scripts can have an inline dependency list so when you ‘uv run’ it will create the environment for you.
2
u/apo383 Jan 02 '25
Yes, I am indeed migrating to uv. I dumped multiple pythons, most of them miniforge, and have standardized on a single homebrew installation with 3.13. I'm able to work on a current project for now, and will eventually have to reconstitute a lot of old conda environments under uv. Everything seems fine from CLI and VS Code, including interactive. The only weird thing is getting used to "uv run".
Apparently reclaimed about 20GB of disk space! I believe I won't lose much back even when I get old environments working, due to uv's caching.
2
u/cointoss3 Jan 02 '25
Yep. uv run. It also pairs nicely with the invoke module. You can write helper scripts for things like building or pushing docker images using Python instead of using Makefiles.
Using invoke, I can do 'uv run inv build' or 'uv run inv push' and it will use invoke to run python functions in the context of my environment from the command line without having to think about if I’m in the right environment.
2
u/cgoldberg Jan 01 '25
I have 2. I use the default Python (3.12) that ships with my Linux distro. I also have an alternate Python installation of the latest version (3.13) for general development. I have no need for anything else.
1
u/apo383 Jan 01 '25
Great, that’s what I want. How are you doing environments? Do you have a single venv, or keep separate ones synced to your 3.13?
3
5
u/Intrepid-Stand-8540 Jan 01 '25
I manage my python versions using uv: https://docs.astral.sh/uv/guides/install-python/
1
Jan 01 '25
What aspect of OPs post is this meant to address?
2
u/Intrepid-Stand-8540 Jan 02 '25
OP is asking how many python versions people have.
That's a weird question. It stinks of https://xyproblem.info/
I assume the real problem he is having is how to manage python versions.
-1
Jan 02 '25
I genuinely can't even tell what you're saying here. OP said he feels like he has too many python versions. Whether he installs them with uv, deadsnakes, apt or anything else is completely irrelevant to whether or not he has installed a bunch of unnecessary python versions for all of his projects.
3
u/apo383 Jan 02 '25
To be fair, I did also ask about how to manage versions. I think my use of miniforge is outdated, and newer tools like uv and pyenv may make it easier to have every environment work with a single, relatively recent, Python version.
4
u/Mrbucket101 Jan 02 '25
Technically 1, the default that comes with MacOS.
I use dev containers for everything. So much easier.
1
1
u/inarchetype Jan 03 '25
Start installing Julia packages and you'll likely end up with 20 or so very quickly.
1
u/apo383 Jan 03 '25
I’m sure I have that many Python packages scattered across envs, it doesn’t bother me. With uv, I think Python version and package management may be comparable with some other languages.
3
u/judah-d-wilson Jan 02 '25
People like to use more than one haha? I've been pushing 3.13 cause pretty colors in the terminal..
5
u/Tweak_Imp Jan 01 '25
One per project, because I develop in a docker container.
1
Jan 01 '25
You have a different python version for every single project?
1
u/Tweak_Imp Jan 02 '25
Not for every one, but if I start a new one, I always choose the newest version that is available and dont upgrade unless it is needed.
1
Jan 02 '25
You said one per project. That would imply every project gets assigned a different python version.
1
2
u/muikrad Jan 01 '25
Hmm, from 3.8 to 3.13 at the moment. Are we glad 3.7 is gone 😁
Then one or more environments per project because "poetry".
I mean, that's the typical setup these days:
Interpreters installed
Dependency management per project with a good tool, using a lock file
A good tool which probably creates virtual envs easily using the lock file from 2
1
1
Jan 01 '25
[removed] — view removed comment
1
Jan 01 '25
OP is talking about python versions, not instances of a virtual environment.
1
Jan 02 '25
[removed] — view removed comment
1
Jan 02 '25
That’s fine but my point is that OP isn’t concerned about space and reducing the number of installed python versions wouldn’t have a significant impact on storage in the way cleaning up lots of old virtual environments would.
20
u/DaveRGP Jan 01 '25
I'm interested in why your goal is the fewest? It seems counter to most software development best practice, which emphasises reproducibility. Python doesn't really take up much space. As long as it's well structured environments (using pyenv, venv, uv, conda or similar) there shouldn't be any concern at all?
For reference I think I likely have at least a dozen python version installs across different machines, and it's never caused me an issue because I've used suitable envinment management for all of them.
Also, that system installed python really needs to be there, and really needs to be left unmodified, btw.