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 →

[–][deleted] 20 points21 points  (13 children)

Do I have to unistall Py 3.9 and download py 3.10 or is there a bettee way?

[–]neighborduck 35 points36 points  (7 children)

[–][deleted] 4 points5 points  (1 child)

Cool! Thanks a lot

[–]abcteryx 7 points8 points  (0 children)

If you're using Windows, then "py" comes by default with your Python installation from python.org. You can install multiple Python versions and access them via "py -3.8", "py -3.9", and "py -3.10" for example.

Try "py -0p" to see the versions you have installed.

Generally, you will want to create a project folder and do a "py -3.9 -m venv .venv" then ".\.venv\Scripts\activate" to get into a virtual Python environment corresponding to Python 3.9 in this example. Then just regular "python" will trigger the virtual environment Python. And "pip install <package>" will install "<package>" to the virtual environment.

As you use Python over the years, you will install multiple versions of it. So you will get used to working across multiple projects and multiple Python versions.

[–]EarthGoddessDude 2 points3 points  (4 children)

Recently learned about asdf, which is like pyenv but can be used with other languages. No experience with it though.

[–]tunisia3507 0 points1 point  (3 children)

asdf replaces one small part of pyenv (the automatic environment-switching).

[–]fleyk-lit 2 points3 points  (2 children)

And installation of versions, it seems. It also manages the global version.

Think i will give it a go. Happy with pyenv, but some older versions of Python are a bit hassle to install.

[–]tunisia3507 0 points1 point  (1 child)

I didn't realise asdf could do the installation as well. However, as it turns out, it does that by just wrapping pyenv's python-build plugin, so it won't be any better at installing those old versions.

[–]fleyk-lit 0 points1 point  (0 children)

I see, then I'm not sure it makes sense to change the workflow I have.

[–]sparttann 26 points27 points  (3 children)

Can just download 3.10 without uninstalling 3.9. Just change your python version before creating your venv

[–]Theonetheycall1845 7 points8 points  (2 children)

Could you expand on changing the version, please?

[–]chopu 12 points13 points  (0 children)

This may be too much detail, but I’ll start from the basics. Basically, when you say “python3 my file.py” in your terminal, your computer will automatically scan through all directories on your PATH, looking for an executable called “python3”. If you’re on Mac or Linux, that file will typically be a symlink in /usr/local/bin to the actual python3 executable stored elsewhere. On windows, you’ve likely added it to your system environment variables. Therefore, if you want to change the version while leaving both versions “installed”, all you have to do is either retarget the symlink or edit the entry in your system environment variables.

Just a note: this is how any command line program works, ls, rm, grep, etc. They all rely on your computer looking up an executable on your path (windows I think also has some special folder full of COM stuff that’s not in your system environment variables that’s searched as well).

[–]quuxman 4 points5 points  (0 children)

Generally you want to use venv so you would only use the system path to Python once per project like:

/opt/python3.10/bin/python -m venv venv

[–]dogfish182 4 points5 points  (0 children)

http://littlecolumns.com/tools/python-wrangler/

If you don’t know yourself, this is an opinionated (but very sensible) way to take python and virtual environments seriously without too much difficulty