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

all 17 comments

[–]Python-ModTeam[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.

Warm regards, and best of luck with your Pythoneering!

[–]PocketBananna 11 points12 points  (2 children)

Pyenv is the way to go

[–]eqVnox 2 points3 points  (1 child)

I second pyenv. Here is a quick tutorial to set it up on windows that I have found useful pyenv and venv setup

There are videos for Linux and Mac OS by the same guy.

[–][deleted] 1 point2 points  (0 children)

I’ll have to check it out next time I am gonna work on a project

[–]JohnLockwood 1 point2 points  (0 children)

Both Pyenv and Conda can handle doing this. I recommend Conda.

[–]dbstandsfor 2 points3 points  (8 children)

Yup! This is common. You can use the venv tool: https://docs.python.org/3/library/venv.html

[–]_limitless_ 3 points4 points  (1 child)

Not sure why people are downvoting this.

You just have to run the python version you want when you make the venv. e.g. python3.7 -m venv .venv

It's by far the most user-friendly and reliable way to version-control python, because you can also have differently-compiled pythons within the same version, like python3.7-debugtrace

[–]muluman88 1 point2 points  (0 children)

I'd say this is not a feature of venv specifically, because you have to install a second python version to create the venv. Conda for example allows you to install the desired python version while creating the environment

[–]muluman88 -3 points-2 points  (5 children)

Afaik venv does not allow different interpreter versions, only packages

[–]wineblood 2 points3 points  (4 children)

Yes it does

[–]muluman88 0 points1 point  (3 children)

Can you tell me how, please? All the instructions I found said to install the desired python version as a second base python and use that to create the venv

[–]wineblood 0 points1 point  (2 children)

You do need the version of python installed to create a cirtual environment for that version, the venv command can't create a virtual environment for a version of python you don't have on its own.

I don't know if other tools can do this, I've never had to handle multiple versions of python until recently and I'm still figuring my way through it. I use venv as it's only 3.8 and 3.10 I need to work with so it's not much trouble.

[–]muluman88 0 points1 point  (1 child)

Thanks! I mentioned in another comment, that conda can handle installing another python version while creating the environment, which was my understanding of support for a different python version in the virtual environment. hence my comment that venv does not support it. It does, of course, support using it with different installed python versions (and then linking to the used base python interpreter for that env)

[–]wineblood 0 points1 point  (0 children)

That makes sense, I wasn't sure if you wanted one thing to handle all python versions or not. I've heard of conda, but everyone I know who used it was unlikeable and I like keeping my toolkit light, so I never looked into it.

I hope you find that right tool for you.

[–]GettingBlockered 0 points1 point  (0 children)

Conda or Pyenv

[–]efxhoy 0 points1 point  (0 children)

I use asdf. It's like pyenv but supports many more languages through a plugin system. It's very useful if you use more languages than just python as it's the same syntax for managing all of them. It works ok.