Python Interpreter Visual Studio Code



  • For VS Code, install Python extension for Visual Studio Code. In VS Code select the Python Interpreter. Hit Ctrl-Shift-P then select option Python: Select Interpreter. The name of the cloned active environment is C:mypatharcgispro-env. So select this in VS Code and it is now linked in to the same python environment used by ArcGIS Pro.
  • I'm fairly new to Stack Exchange and not very well-versed in IDE's. I'm struggling to set up the ArcGIS Pro Python interpreter with Visual Studio Code. I have ArcGIS Pro 2.4.3 and VSC 1.44.2. I'm trying to follow the advice on the below thread, but I cannot ask questions in that thread, only add answers. Original Thread. So here's my question.

In this quick blogpost, I will share the steps that you can follow in order to install a Python library using pip through either the Terminal or a Jupyter Notebook in Visual Studio Code (VSCode) on a Windows computer.

In Visual Studio Code's built in terminal which python gives /usr/bin/python Since I want to use anacondas python installation I use CMD+SHIFT+P (Python: Select Interpreter) and there I see /anaconda3/bin/python so I select that one. However this does not take effect in my terminal. Visual Studio Code (VSC) is a free cross-platform source code editor. The Python for Visual Studio Code extension allows VSC to connect to Python distributions installed on your computer. Python in Visual Studio Code Working with Python in Visual Studio Code, using the Microsoft Python extension, is simple, fun, and productive. The extension makes VS Code an excellent Python editor, and works on any operating system with a variety of Python interpreters.

Pre-requisites

In order to complete the steps of this blogpost, you need to install the following in your windows computer:

  • Visual Studio Code: you can find the steps to install it here.
  • Python Extension for Visual Studio Code: you can find the steps to install it here.
  • Python Interpreter: you can find the steps to install it here.

Installing a Python Library Using the Terminal in VSCode

1) Accessing Visual Studio Code Terminal

  • Open VSCode application
  • Go to the Terminal menu and select New Terminal.
  • A new terminal (PowerShell based) window is opened.

2) Importing a Python Library

  • Run the following command to validate that pip is installed in your computer.
  • Let us say that you want to install Pandas Python library.
  • Run the following command
  • Pandas library is now ready to be imported by any python application. You can repeat this process for any Python library.

Installing a Python Library Using a Jupyter Notebook in VSCode

1) Creating a Jupyter Notebook in VSCode

  • Create a Jupyter Notebook following the steps of My First Jupyter Notebook on Visual Studio Code (Python kernel)

2) Importing a Python Library

  • Run the following command to validate that pip is installed in your computer.

Visual Studio Code Anaconda

  • Let us say that you want to install Pandas Python library.
  • Run the following command.
  • Pandas library is now ready to be imported by any python application. You can repeat this process for any Python library.
Python Interpreter Visual Studio Code

Subscribe to Open Threat Research Blog

Get the latest posts delivered right to your inbox

I’m starting to really, really, like MicroPython. I particularly like the way that you can use the REPL command prompt to test out code before dropping it into your programs. I’ve been using an editor called Thonny which is nice enough but of course what I really want is to be able to use Visual Studio Code. It turns out that there’s a plugin for this. It’s called Pymakr. It lets you transfer Python files between your PC and your MicroPython device and provides a REPL prompt too. If you want to use it you have to install Node.js first. I did this and then found that it didn’t work. My MicroPython board was not detected.

I was using one of my Doit boards which usually works fine. (I’ve just bought another one….) It turns out that Pymakr maintains a list of USB devices that it is willing to connect with. You need to make sure that your device is on the list in the configuration file Pymakr.json. Use the command Pymakr>Global Setting to open this file and then add your device manufacture to the list, like I’ve done below.

Note that this is not the the manufacturer of your device, it is the manufacturer of the USB interface that the device uses to connect to the PC.

You can find the name that you need by opening Device Manager, right-clicking the com port where your board is connected and then getting the manufacturer name from the properties page:

I did this and everything started working. The Pymakr plugin has a nifty feature where it will copy all the Python files in your project into the device, or only copy the ones that you’ve changed. Very nifty.

Python Select Interpreter Visual Studio Code

If you’ve not played with MicroPython before I’ve written a tiny guide that you might find useful. You can find it here.