TL;DR
This question is NOT asking how to select a Python Interpreter to run, or debug, code with, furthermore; this question is NOT asking anything in regard to Virtual Environment, or how to activate a Virtual Environment, all of that is working. I feel it is important to note, that the question below has been asked previously, but failed to receive a satisfying answer due to confusion over what was being asked. Community Members often think one of the questions, that I mentioned at the beginning of this question, is being asked, here is a question that's a good example of what I just wrote here.
Here is My Question:
How can a user configure their Integrated Terminal to use an Interpreter that the user specifies?
I want to be able to configure my terminal to use the interpreter in my virtual environment — their is an example of my virtual environments interpreter in the Screenshot below.
from the status bar that the VENV interpreter is active, and my code runs fine.
from the Windows Terminal the system interpreter is being used.
The problem that is caused by this, is that I can't run pip or other packages like PyInstaller from the Integrated Terminal because its not looking inside of my VENV, and furthermore; I don't want to globally install the packages.
Another problem that occurs is that, parts of my app include version sensitive packages, and I need to control the version of the python interpreter used by the Integrated Terminal.
sys.executable
? And what you would like it to be? – Blowbyblowsys.executable
returns my system interpreter "'C:\\Users\\mark\\AppData\\Local\\Programs\\Python\\Python37\\python.exe'". I want the terminal window to use the interpreter in my venv, but in general point it to any interpreter I chose, my venv directory is "C:\Users\mark\OneDrive\dev\babyclix\.venv\Scripts". As the screen shot shows, terminal uses 3.7.7 and venv 3.7.0. – Greenheartecho %PATH%
. Then, runC:\Users\mark\OneDrive\dev\babyclix\.venv\Scripts\activate.bat
and checkecho %PATH%
again. What did change? The first folder withpython.exe
is the one started when you runpython
. – BlowbyblowC:\Users\mark\OneDrive\dev\babyclix\.venv\Scripts
. There you should find the reason for the described behaviour. – Blowbyblow.venv
incmd.exe
, what is output ofwhere python
? After activating.venv
in VS Code terminal, what is output ofwhere python
? Is there any difference? – Blowbyblowwhere python
command returns nothing in cmd.exe, and the system interpreters in VSCode. Changing the interpreter to the venv one and restarting VSCode does not change the Terminal interpreter. – Greenheartwhere python
incmd.exe
? It would mean that it does not find anypython.exe
and should throw an error if you try to runpython
. – Blowbyblowwhere python
doesn't give an error, it just returns nothing. The commandpython
returns the venv python version. I have used VSCode and Terminal a lot without problem as well. You should be able to reproduce it by installing python3.9 or some version you don't have on your machine, including it in your path, rebooting VSCode, and typepython
in the Terminal to see what version it is picking up. – Greenheart.python-version
file in your project directory andpyenv
would automatically activate the correct environment in your terminal (as soon as it switches into your project directory containing the.python-version
file. – Saturn