Open-source News

Using Python in VS Code and Codium

opensource.com - Wed, 11/09/2022 - 16:00
Using Python in VS Code and Codium Don Watkins Wed, 11/09/2022 - 03:00

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

More Python resources What is an IDE? Cheat sheet: Python 3.7 for beginners Top Python GUI frameworks Download: 7 essential PyPI libraries Red Hat Developers Latest Python articles 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.

Image by:

(Opensource.com, 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 ~/PythonCodingAdd 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/app.py
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.

If you're looking for a good, general-purpose, open source code editor with Python integration, then you might give Codium a try.

Image by:

WOCinTech Chat. Modified by Opensource.com. CC BY-SA 4.0

Python Linux What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

The Most Used Operating Systems in the World

Tecmint - Wed, 11/09/2022 - 13:35
The post The Most Used Operating Systems in the World first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Brief: This article explores some of the most popular and widely used operating systems in the world. If you have ever used a PC, Macbook smartphone, tablet or any smart device (which is likely

The post The Most Used Operating Systems in the World first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Intel Releases November 2022 CPU Microcode For Various Functional Issues

Phoronix - Wed, 11/09/2022 - 08:28
Intel today published their "20221108" CPU microcode collection alongside announcing various security disclosures for the quarter. Fortunately on the CPU microcode side, the changes are all focused on functional issues...

Leading Organizations Accelerate Innovation in the Industrial Sector with Red Hat

Red Hat News - Wed, 11/09/2022 - 08:00
<p><span><span><span><span><span><span>Digital Transformation has been well underway for many organizations looking for ways to effectively modernize, drive operational efficiencies and improve production in the industrial sector. Organizations in the manufacturing industries in particular, have relied on proprietary solutions and vertically-integrated vendors to address their immediate computing needs, but that seems to be changing as leaders are leaning toward capabilities that help grow and res

AMD Joins The Cloud Hypervisor Project Started By Intel

Phoronix - Wed, 11/09/2022 - 03:00
Over the past three years one of Intel's many promising open-source software projects has been the Rust-written Cloud Hypervisor. Cloud Hypervisor started as just a modern, security-focused, cloud-centric Rust VMM hypervisor for modern hardware/software. It began as just one of many open-source software projects at Intel but last year was folded into the Linux Foundation umbrella while Intel continues to be a major contributor to the project. Coming as a bit of a surprise today is AMD announcing they have joined the Cloud Hypervisor project...

Fedora 38 Looking At A Phosh Image For Mobile Devices

Phoronix - Wed, 11/09/2022 - 01:30
It looks like Fedora could be taking on more mobile ambitions with a Phosh image now proposed for running that Wayland shell focused on smartphones and tablets while delivering a good GNOME-based experience. Separately, a change proposal is expected for also introducing a Fedora Linux image with KDE Plasma Mobile...

NVIDIA Makes The PhysX 5.1 SDK Open-Source

Phoronix - Tue, 11/08/2022 - 23:17
Back in 2019 NVIDIA open-sourced the PhysX 4.1 SDK and was working on a PhysX 5.0 open-source code drop while we haven't heard anything more on the matter in the past two years. Coming out this morning as a surprise is the NVIDIA PhysX 5.1 SDK open-source release...

ASRock X670E PG Lightning - Nice AMD Zen 4 Motherboard For $250 USD

Phoronix - Tue, 11/08/2022 - 23:00
When it comes to new AMD AM5 motherboards featuring an X670 series chipset, one of the cheapest options right now is the ASRock X670E PG Lightning that retails for around $249 USD. I picked up one of these motherboards at launch and has been working out well on Linux for those wanting to build a cost-minded AMD Zen 4 desktop system.

Pages