0

The python interpreter that I choose is python 3.7.16(tf:conda )which is set by anaconda. And its path in my computer is F:\anaconda\envs\tf\python.exe. In the user's setting.json , I changed the interpreter path to F:\anaconda\envs\tf\python.exe.

enter image description here

But when I run my code in vscode, it uses a different interpreter other than the one that I chose, and its path is F:\python \python 310\ python.exe

enter image description here

Ch3steR
  • 20,090
  • 4
  • 28
  • 58
AugLeo
  • 1
  • 1
  • Possibly related: https://stackoverflow.com/questions/63644980/how-to-make-python-as-default-interpreter-in-vs-code and https://stackoverflow.com/questions/72571271/vs-code-python-envfile-does-not-seem-to-work-with-python-defaultinterpreterpa – slothrop Apr 19 '23 at 12:52

2 Answers2

1

Obviously you are using Code Runner to run the code. This is incorrect, because selecting an interpreter is a feature of Python extension, so the interpreter you choose is only valid for Python extensions (that is, the actual interpreter version in the lower right corner).

If there is no special requirement, please use the official extension Python to execute the script.

enter image description here

The Run Code option is brought by Code Runner

Code Runner does not use the settings made for the Python extension, so it executes the script using the python version configured by the system environment variable.

JialeDu
  • 6,021
  • 2
  • 5
  • 24
0

It is because your environment path of python is set to "F:\python \python 310\ python.exe". You have to replace this path with the path you want in your Operation System environment path.