Labs / MicroPython tutorials / 02 Setting up the MicroPython Development Environment — Draft Document Tutorial

Building MicroPython Development Environment with Linux and VSCode (Pure Local Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.0 · License: CC BY 4.0

Contents

I. Install Miniconda

Miniconda is a lightweight version of Anaconda, designed specifically for managing Python virtual environments to prevent contamination of the system's Python installation.

1.1 Download the Miniconda installer

# Download the Linux version of Miniconda (Python 3.10 stable release)
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh

If the download is slow or fails: confirm that your terminal proxy is active (the export http_proxy=. .. you configured earlier), and the download will be fast if the proxy is working properly.

repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh 154.56MB/s 44 162067098 1.1

1.2 Run the installation script

# Run the install script (just press Enter/yes all the way through)
bash miniconda.sh
23.5.2-1.1
20.04 Home/Testing/miniconda3 miniconda3
16.04

During the installation process, you will be asked "Whether to initialize conda", please select yes (critical! Otherwise the conda command will not be available).

The successful installation result is shown as follows:

18.04 home/temp/ghp/Miniconda3/conda 4.15.8

1.3 Restart the terminal / make conda take effect

After the installation is complete, close the current terminal, open a new terminal, and enter the following command:

conda --version
26.1.1 1.3

can output version numbers like conda 23.x.x, which indicates that Miniconda has been installed successfully.

2. Create a dedicated MicroPython virtual environment

Use conda to create an isolated environment to avoid conflicts with other Python projects.

2.1 Create an Environment

# Create an environment named "micropython" with Python version 3.12
conda create -n micropython python=3.12 -y

The parameters are defined as follows:

Note that after running this command, it may not work properly. You need to accept the terms of service of the official channel first. Let's accept the terms before proceeding to create the environment:

3.12 2

After the terms acceptance is completed, you can just execute the previous creation command.

Building MicroPython Development Environment with Linux and VSCode (Pure Local Version)

Here is how to use the environment:

64

2.2 Activate the virtual environment

# Activate the environment (the terminal prefix will become (micropython))
conda activate micropython
2.2

All subsequent operations must be performed after the environment is activated.

3. Install the mpremote tool

mpremote is the official remote operation tool for MicroPython, which is used to transfer code to development boards, run code, and perform debugging.

# Install mpremote in the activated conda environment
pip install mpremote
1.12.0

Verify the installation: Enter mpremote --version, if the version number is output → the installation is successful.

Next, configure serial port permissions for mpremote (to avoid the "Permission Denied" error):

# Add the current user to the serial port group (dialout)
sudo usermod -aG dialout $USER
# Reboot for it to take effect (a reboot is required!)
sudo reboot
Building MicroPython Development Environment with Linux and VSCode (Pure Local Version)

IV. Install VSCode and plugins

First, install VSCode:

# 1. Install the required dependencies (used for adding the HTTPS source)
sudo apt update && sudo apt install -y wget gpg apt-transport-https

# 2. Download and add the official VSCode GPG key (verifies the source's legitimacy)
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/packages.microsoft.gpg

# 3. Add the official VSCode software source to the system
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null

# 4. Delete the temporary key file
rm -f packages.microsoft.gpg

# 5. Update the apt cache (will go through the proxy you configured)
sudo apt update

# 6. Install VSCode (the core command)
sudo apt install -y code
18.04
18.04

Open VSCode, click the "Extensions" icon (four small squares) on the left, and install the following plugins in sequence:

Plugin NameAuthor / SourceCore function
PythonMicrosoftPython base environment support, intelligent completion, syntax checking, debugging
Code Completion for MicroPythonwalkline-wangCode completion and library function hints for MicroPython-specific modules
Micropython-REPLinkswc-fablabQuick code upload, REPL interaction, remote script execution
Serial MonitorMicrosoftSerial data transmit/receive, log printing, debug information viewing
Building MicroPython Development Environment with Linux and VSCode (Pure Local Version)
1.1.1 1.1K 3.7 3.10
0.1.0
1.0.0

5. Configuring Python Interpreter in VSCode (Associating with conda Environment)

Open VSCode → Press Ctrl + Shift + P to open the "Command Palette":

20.04 0.1.0 2021 12

Enter Python: Select Interpreter, then locate the conda category in the pop-up list and find the micropython environment (the path is similar to ~/miniconda3/envs/micropython/bin/python):

3.12.12 miniconda3/envs/micropython/bin/python

Select this environment → the status bar at the bottom will display Python 3.10.xx ('micropython': conda)→ configuration succeeded.

VI. Verify the Entire Environment

Connect the Raspberry Pi Pico (or other MicroPython development board) to your computer using a USB cable;

Open the VSCode terminal and activate the conda environment first:

conda activate micropython

Detection Development Board:

# List the connected MicroPython devices
mpremote lt

Output something like /dev/ttyACM0 → development board detected;

micropython_bma400

Connect the development board:

mpremote 

Test and run the code in REPL:

# Turn on the development board LED
from machine import Pin 
Pin(25, Pin.OUT).value(1)

The LED on the development board lights up → The environment is completely normal!

dev/ttyACM0 Pin25 1

Version Record

Version Number

Revision Date

Modifier

Modified Content

v1.0

2026-03-11

Lee Eonyong

Initialization version.