Python Forum

Full Version: I can't use Python 3.10
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! I hope that I'm writing in the right category.

I want to use the 3.10 version for a script, but I'm struggling to use this version. I installed it, but when I type python --version it gives me the 3.9.10 version only.

What can I do to use the 3.10?
python --version will list the version of python runs when you type "python". This may not be the most recent version.

What is printed if you type this in a shell:
Output:
py --list
Does it show -3.10 as well as 3.9.10?

Are you running in a virtual environment?

Are you on Linux, Mac or Windows?
python version was 3.1, not 3.1.0 released on 13 February 2009
sane with 3.2 which was released on 20 February 2011

versions beginning with 3.0.0 contained the third division

see: https://www.python.org/doc/versions/


EDIT:
Sorry, you asked about 3.10. I misread.

try to find installed python3 versions

from subprocess import check_output
import sys

# find all installed python3 versions
python_version = ""
python_versions_list = []
versions = check_output("which -a python3", shell=True).decode()
versions_list = versions.splitlines()

for v in versions_list:
    version = check_output(f"{v} --version", shell=True).decode().rpartition(".")[0].split(" ")[1]
    python_versions_list.append(version)
    print(f"found python{version}")

python_version = f'python{sys.version.split(" ")[0].rpartition(".")[0]}'

print("default python3 version:", python_version)
(Feb-20-2022, 09:31 PM)deanhystad Wrote: [ -> ]python --version will list the version of python runs when you type "python". This may not be the most recent version.

What is printed if you type this in a shell:
Output:
py --list
Does it show -3.10 as well as 3.9.10?

Are you running in a virtual environment?

Are you on Linux, Mac or Windows?

Hello! I'm on Mac and I don't use a virtual environment. When I type your command in the terminal, it gives me zsh: command not found: py
(Feb-21-2022, 12:29 PM)Axel_Erfurt Wrote: [ -> ]try to find installed python3 versions

from subprocess import check_output
import sys

# find all installed python3 versions
python_version = ""
python_versions_list = []
versions = check_output("which -a python3", shell=True).decode()
versions_list = versions.splitlines()

for v in versions_list:
    version = check_output(f"{v} --version", shell=True).decode().rpartition(".")[0].split(" ")[1]
    python_versions_list.append(version)
    print(f"found python{version}")

python_version = f'python{sys.version.split(" ")[0].rpartition(".")[0]}'

print("default python3 version:", python_version)

There is the result: Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin