Using Python in VS Code and Codium

If you're looking for a good, general-purpose, open source code editor with Python integration, then you might give Codium a try.
4 readers like this.
Hands on a keyboard with a Python book

WOCinTech Chat. Modified by CC BY-SA 4.0

Over the past couple of years, I have had the privilege of working with middle school children to introduce them to Python coding and the Raspberry Pi 400. It's been a lot of fun, and the Pi has been a great platform for the students and me. We've used Code with Mu and it's been quite successful. Our aptitude with Python has grown with experience, and so recently I started looking for ways to offer these students more.

I participated in a Python learning class, and during that class I got introduced to Microsoft's Visual Studio Code. I learned a lot in that class about how to set up a virtual environment for Python, and how to configure VS Code for Python programming. During that learning journey, I also got introduced to Codium, which is essentially VS Code without Microsoft's branding and telemetry.

If you're looking for a good, general-purpose, open source code editor with Python integration, then you might give Codium a try. Here's how I got Codium set up for Python on my Linux system.

Install or update Python on Linux

First, make sure you are running the latest version of Python. You can do this with your package manager. On Debian and Debian-based systems:

$ sudo apt install python3-pip

On Fedora, CentOS, Mageia, OpenMandriva, and similar:

$ sudo dnf update python3

On some systems, you may also need to install the software to create Python virtual environments:

$ sudo apt install python3.10-venv

Install Codium

Next, install Codium on your computer. On Linux, you can download a package and install it with your package manager, or use the Flatpak.

To launch Codium once it's installed, open your application or Activities menu and type "Code".

Install the VS Code Python extension

There's nothing special about code. It's just plain text that gets interpreted by some other application, whether it's a compiler or a runtime. You can write Python code in Codium without special extensions. However, having a Python extension adds several conveniences.

Click on the File menu, select Preferences, and choose Extensions. In the Extensions panel, find the Python IntelliSense extension.

VS Code and Codium have an extension manager that opens in the left column, allowing you to install add-on modules.

(, CC BY-SA 4.0)

You've got Python set up in Codium. All that's left to do is to put it to good use.

Setup a virtual environment for VS Code or Codium

You can create a project directory and add it to Codium so that while you work, the files you create and save default to the active project directory. It's a fast way to stay organized, and it saves you from having to click around File Save and Open dialogues constantly.

When you create a virtual Python environment as a work folder, Codium (because you have the Python extension installed) detects it. When you activate a virtual environment folder as the active project directory, Codium automatically runs the activation code required to use the virtual environment.

To create a virtual environment for Python, open a terminal and type:

$ python3 -m venv ~/PythonCoding

Add a project directory

In Codium, click on the File menu and choose Add Folder to Workspace. Open the virtual environment you've just set up (for me, that's /home/don/PythonCoding.)

Now you're ready to write some Python code! Create a new Python file in your workspace and insert some basic code. You may notice, as you type, that Codium helpfully suggests auto-completion for the Python modules the environment contains.

import sys
print ("Codium running Python " + sys.version)

Now click the Play button in the top right corner of the Codium window. This opens a console panel at the bottom of the window, displaying the output of your code:

(PythonCode) sh-5.1$ /home/bogus/PythonCode/bin/python /home/bogus/PythonCode/
Codium running Python 3.10.6 (main…) [GCC 12.1.0]
(PythonCode) sh-5.1$

As you can see from this output, Codium is running within the PythonCode environment, and it's successfully run your Python code.

Codium and Python

Using Codium for Python makes writing and running code easier than ever, but Python isn't the only language Codium supports. You can easily find and install other extensions from the Open VSX Registry, a vendor-neutral open source "marketplace" for VS Code extensions.

The Codium interface is more complicated than some basic editors, but it has what I'm looking for at this point in my learning journey. If you're looking to graduate to something professional, or you're looking to switch from your current editor to something new, then give Codium a try.

User profile image.
Educator, entrepreneur, open source advocate, life long learner, Python teacher. M.A. in Educational Psychology, M.S. Ed. in Educational Leadership, Linux system administrator.

Comments are closed.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.