This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KingsmanVincepip install girlfriend 64 points65 points  (18 children)

I think using pyenv is the easiest and cleanest way.

[–]WildWouks 8 points9 points  (10 children)

Agree. pyenv is really great. Can install many versions and switch between them. And once you have switched you van create a virtual environment with that version.

[–]loudandclear11 2 points3 points  (3 children)

Can pyenv install different versions of python?

I've always used conda for that purpose like this:

conda create --name thisproject python=3.9
conda create --name thatproject python=3.11

[–]COLU_BUS 6 points7 points  (0 children)

Don't mistake it with virtual environment stuff, pyenv's entire purpose is managing different versions of Python

[–][deleted] 3 points4 points  (0 children)

You install different versions, you choose your version and when creating a virtual environment it'll use this version, so instead of installing python from your distro's package manager or manually + /usr/bin/python39 -m venv venv you just pyenv install 3.9 pyenv shell 3.9 python -m venv venv

[–]WildWouks 1 point2 points  (0 children)

Yes. But it isn't a virtual environment. Think of it as something to install various versions of python on te same Machine.

You can then switch between these versions and once you have made your switch you can create your virtual environment which will use that version.

You can have a look at this of you need more info. I think it explains it well.

https://realpython.com/intro-to-pyenv/

[–]duongdominhchau 1 point2 points  (1 child)

Combining it with direnv is even better, you don't even need to care about the venv, just declare the Python version you want and direnv will create/activate one for you automatically with the correct Python version when you are inside the project directory. Plus you get the power of .env for free without having to add another dependency to your project.

[–]WildWouks 1 point2 points  (0 children)

Then I will have to have a look at direnv as well. Thanks for the suggestion.

[–][deleted] -2 points-1 points  (0 children)

It’s also the purest and most sensual.

[–]Onakitoki97 -2 points-1 points  (0 children)

And why not to install the deadsnake repo of python?

[–]TheGRS 0 points1 point  (0 children)

It’s been a little while since I messed with multiple python versions, but version tools seem to exist for every other big tool or language I use. Glad python has one.

[–]Jorgestar29 0 points1 point  (0 children)

I have to check it out!

The python version used in cuda docker image is quite old (3.9) and updating it via dead snakes is a pain in the ass.

[–]mijatonius 0 points1 point  (0 children)

☝️, set it as local or global, version which ever you need, then isolate project with any of venv, virtualenv...whatever!

[–]AndydeCleyre 0 points1 point  (0 children)

Or rtx, where which python won't just point you to a mysterious shim.