Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting python interpreter in VSCode

I am using VSCode with ArcGIS Pro 3.0 in a virtual environment. Until yesterday, everything worked just fine. After updating to Pro 3.0, I was still able to use open a script and then have it run in the terminal window.

Previously, I was able to select a line from the script, run it, and then it would open the correct interpreter. However, now I am unable to do so and cannot troubleshoot why this is happening. I have added the correct path to the ArcGIS Pro python executable in the interpreter path, but the terminal opens to another python executable. Any advice would be greatly appreciated as to how I can run specific python executable that I want to run.

UPDATE: I can open VSCode using code from my anaconda installation, but still am having trouble running python interactively in the terminal. Previously, I used to be able to do this (e.g. test indented code cells), but this doesn't seem to be functioning anymore.

like image 340
user44796 Avatar asked Feb 19 '26 12:02

user44796


2 Answers

You should be able to point VSCode to a specific python interpreter in a virtual environment - you can access this via View > Command Palette > Python: Select Interpreter

Select Interpreter Window

Then once you open a .py file you should see the python interpreter in the bottom right portion of the window, and if you open a new terminal it will use that specified interpreter

Some other references:

  • How do I set standard Interpreter path for python in vscode config json?
  • Visual Studio code is not loading my python interpreters
  • https://code.visualstudio.com/docs/python/environments
like image 176
smoot Avatar answered Feb 22 '26 01:02

smoot


To select a specific Python interpreter with ArcGIS Pro 3.0 within a virtual environment in Visual Studio Code (VSCode), you can follow these steps:

  1. create a virtual environment. ArcGIS Pro 3.0 comes with its own Python installation, you need to ensure that the virtual environment is set up correctly to use that Python version.

    python -m venv myenv

  2. Activate the virtual environment. on windows: myenv\Scripts\activate on macos : myenv/bin/activate

  3. Press Ctrl + Shift + P (or Cmd + Shift + P on macOS) to open the Command Palette.

  4. Type Python select interpreter and press Enter.

  5. In the list of available interpreters, you should see the Python interpreter from your virtual environment. It might be named something like "myenv".

  6. Select the desired Python interpreter from the list

now you will get your desired interpreter.

like image 24
Jeewan Ghimire Avatar answered Feb 22 '26 01:02

Jeewan Ghimire