(Sep-04-2022, 03:35 PM)bytecrunch Wrote: I think I am missing a piece about virtual environments: we don't use pip to add a Python interpreter to the virtual environment. So how do we connect a specific Python interpreter version to a virtual environment? What are the commands?You are talking about venv that comes with Python?
Usually use the lasted version have on OS,but can use any version that is installed.
Example:
G:\div_code λ python -V Python 3.10.5 G:\div_code λ python -m venv new_env G:\div_code λ cd new_env\ G:\div_code\new_env λ G:\div_code\new_env\Scripts\activate (new_env) G:\div_code\new_env λ python -V Python 3.10.5Let say i want to use Python 3.7 that have installed,then can use
py
(comes with Python).G:\div_code λ py -3.7 -V Python 3.7.3 G:\div_code λ py -3.7 -m venv new_env G:\div_code λ cd new_env\ G:\div_code\new_env λ G:\div_code\new_env\Scripts\activate # Environment will now use 3.7 (new_env) G:\div_code\new_env λ python -V Python 3.7.3There are 3-party packages that can install a new Python version to a environment(not on OS) like Anacondas conda ,
or Poetry with pyenv on Linux.
Poetry is really good so worth to take a look.
Quote:Ok on IDEs non coming with an interpreter. I guess the IDLE did when I downloaded it.No,but PyCharm will usually find any Python version if there is any on the OS.
Look at Configure a Python interpreter PyCharm
There see how to choice an exiting interpreter or virtual environment.