python version depends on version venv module called from. for example one way would be:
%python --version
Python 3.8.3
%python -m venv venvpy3.8
if activate the env with the default version which is 3.8.3 here.
to find all python versions in my system, following script helps:
from os import listdir
from os.path import isfile, join
import re
python_re=r"^python\d"
path=os.environ["PATH"]
probable_python_versions=[]
for e_path in path.split(":"):
python_versions=[os.path.join(e_path,file_folder) for file_folder in listdir(e_path) if isfile(join(e_path, file_folder)) and (re.match(r"^python\d\.\d+$",file_folder)) ]
probable_python_versions.extend(python_versions)
print(probable_python_versions)
so it provides a list as
['/opt/anaconda3/bin/python3.8',
'/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8',
'/usr/local/bin/python3.8',
'/usr/local/bin/python3.11',
'/usr/local/bin/python3.9',
'/usr/bin/python2.7']
now a need is for virtual env with 3.11, a way would be
% /usr/local/bin/python3.11 -m venv venvpy3.11 and can activate and this env will have python 3.11