aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Programming
  • Technology

Visual Studio Code for Python and Data Science? Top 3 Plugins You Must Have

  • root
  • October 25, 2021
  • 4 minute read

Is it the best code editor for Python and Data Science?

Are you struggling to find an optimal code editor for Python programming and data science? You’re not alone. There’s a ton of options to choose from — both free and paid — and today I’ll show you my favorite free one.


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

It’s Visual Studio Code — a completely free code editor from Microsoft. It’s by far the most flexible and feature-rich code editor I found. It even has more features than PyCharm Community, which is supposed to be a professional IDE. And don’t even get me started on Jupyter — it’s probably the best way to write notebooks, but notebooks alone aren’t enough for data professionals.

Today you’ll see my go-to approach for setting up VSCode for Python programming and data science. We’ll start with the installation and go through the plugins from there.

Don’t feel like reading? Watch my video instead:

 

Download and install Visual Studio Code

Head over to code.visualstudio.com to download VSCode. The webpage should detect your OS automatically, so you only need to hit the big blue download button:

Image 1 — Visual Studio Code home page (image by author)

On Mac, it will download a ZIP file which you can extract and drag the app to the Applications folder. On Windows, I assume you need to open the .EXE file and click on Next a couple of times, and for Linux, it’s probably either a Terminal command or a DEB file.

Here’s what you should see once you launch it:

Image 2 — Visual Studio Code (image by author)

You can create a Python file by opening any folder on your machine, right-clicking the left sidebar and selecting New file. I’ve created a folder on Desktop and a main.py file in it:

Read More  Top 5 Programming Languages Web Developers Should Learn
Image 3 — Creating a Python script in VSCode (image by author)

By default, you won’t have the best debugging options, nor you’ll have IntelliSense. You also won’t be able to select a virtual environment. Fixing this is quick and easy. You only need to install a plugin. But let’s address something more urgent first.

Download a theme (optional)

The first thing I like to do in VSCode is to change the theme. It has nothing to do with Python and data science, so you can either skip this section or consider it as a bonus point.

The default theme is just too Microsofty for me. To change it, you can click on the Extension tab and search for themes. I particularly like the One Dark Pro theme, which is free, even though it says Pro:

Image 4 — One Dark Pro theme (image by author)

Click on the theme and hit the Install button. The default skin is a bit too light for my liking. On Mac, you can press CMD+K CMD+T to open the theme dropdown. My favorite is One Dark Pro Darker:

Image 5 — Using a custom theme (image by author)

Much nicer, isn’t it? Let’s address the extensions next.

Official Python extension

This one is a must-have if you want to work with Python. Go to the Extensions tab once again and search for Python. You should install the official extension from Microsoft:

Image 6 — Official Python extension (image by author)

You’ll now have a much easier time writing Python files. You can also choose a virtual environment now, which is something you’ll do daily. Click on the bottom left text that says Python 3.9.7 64 bit (at least on my machine) and select any environment you want:

Image 7 — Choosing a virtual environment (image by author)

Do you know what the best part is? You can immediately start working with Jupyter Notebooks! Create a .ipynb file to verify — it might prompt you to install some additional dependencies, so just agree to everything.

Read More  The Right And Wrong Way To Set Python 3 As Default On A Mac

Once installed, you can enter Python code to a cell to verify everything works:

Image 8 — Testing Jupyter Notebooks (image by author)

And that’s it — you now have the basics installed, so you can work with Python either through scripts or through notebooks. Let’s add some additional functionality next.

Python docstring generator

One essential tip for writing good Python code is documentation. VSCode can help you with that. All you need to do is to install the Python Docstring Generator extension.

Image 9 — Python Docstring Generator extension (image by author)

Let’s see how it works. You’ll write a dummy Python function that sums up two integers:

def add(a: int, b: int) -> int:
    return a + b

Write the function inside main.py:

Image 10 — Dummy Python function (image by author)

You can now add a docstring by writing three double quotes below the function declaration and selecting the Generate Docstring option:

Image 11 — Docstring generator (image by author)

It will immediately write the boilerplate for you:

Image 12 — Docstring boilerplate (image by author)

All you’ll have to now is to edit the description and the role each parameter has:

Image 13 — Editing the docstring (image by author)

That’s much easier than writing everything from scratch. Maybe you don’t see the benefit because we have only one function, but imagine you had multiple Python modules, each having dozens of functions — then this extension is a huge time saver.

Python linter

And finally, I want to discuss linting. You can enable linting in VSCode to automatically tell you if you’re not following Python conventions. It will tell you if you have unused imports, variables, or if there’s anything to improve in your code.

To start, open up the Command Palette (Settings — Command Palette… or press SHIFT + CMD + P) and type in Linter. Choose the Select Linter option:

Read More  New Analyst Report Recognizes Retarus Among Notable Vendors For Enterprise Email Security
Image 14 — Selecting Python linter (image by author)

PyLint is the most popular one, so just click on it:

Image 15 — Linter options (image by author)

It will ask you to install PyLint if it’s not installed already. You’ll have to repeat the process for every virtual environment, so keep that in mind:

Image 16 — Installing PyLint (image by author)

Let’s now delete the add() function and explore what PyLint has to offer. You’ll import json and random modules and print a random integer between 1 and 100:

import json 
import random

print(random.randint(1, 100))

Here’s how it should look like:

Image 17 — Warning messages (1) (image by author)

You’ll see warning messages as soon as you save the file. The print statement complains because there’s no new line after it, but that’s a quick fix — just hit Enter at the end of the line.

The top import statement is underlined because we don’t have a file-level docstring on the top, so let’s write one quickly:

Image 18 — Warning messages (2) (image by author)

The warning won’t go away if you save the file. It now complains that you’ve imported json but aren’t using it in the file:

Image 19 — Warning messages (3) (image by author)

The message will go away once you delete the unused import.

To summarize, linters can help you write better Python code and make sure you’re following all the conventions. Your code will still run if the linter gives you warning messages, but it’s annoying to look at them, so you’ll likely address them as they come.

And that’s it for today. My Python and data science setup in VSCode is somewhat simplistic, but it gets the job done.

What are your favorite VSCode extensions for Python and data science? Please let me know in the comment section below.

This article was republished from towardsdatascience.com


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

root

Related Topics
  • Apple Developer
  • Data Science
  • OS
  • Programming Language
  • Python
  • Visual Studio
  • VSCode
You May Also Like
Getting things done makes her feel amazing
View Post
  • Computing
  • Data
  • Featured
  • Learning
  • Tech
  • Technology

Nurturing Minds in the Digital Revolution

  • April 25, 2025
View Post
  • People
  • Technology

AI is automating our jobs – but values need to change if we are to be liberated by it

  • April 17, 2025
View Post
  • Software
  • Technology

Canonical Releases Ubuntu 25.04 Plucky Puffin

  • April 17, 2025
View Post
  • Computing
  • Public Cloud
  • Technology

United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services

  • April 15, 2025
View Post
  • Technology

Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology

  • April 2, 2025
View Post
  • Software
  • Technology

IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management

  • March 27, 2025
View Post
  • Technology

IBM contributes key open-source projects to Linux Foundation to advance AI community participation

  • March 22, 2025
View Post
  • Technology

Co-op mode: New partners driving the future of gaming with AI

  • March 22, 2025

Stay Connected!
LATEST
  • college-of-cardinals-2025 1
    The Definitive Who’s Who of the 2025 Papal Conclave
    • May 7, 2025
  • conclave-poster-black-smoke 2
    The World Is Revalidating Itself
    • May 6, 2025
  • 3
    Conclave: How A New Pope Is Chosen
    • April 25, 2025
  • Getting things done makes her feel amazing 4
    Nurturing Minds in the Digital Revolution
    • April 25, 2025
  • 5
    AI is automating our jobs – but values need to change if we are to be liberated by it
    • April 17, 2025
  • 6
    Canonical Releases Ubuntu 25.04 Plucky Puffin
    • April 17, 2025
  • 7
    United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services
    • April 15, 2025
  • 8
    Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology
    • April 2, 2025
  • 9
    IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management
    • March 27, 2025
  • 10
    Tariffs, Trump, and Other Things That Start With T – They’re Not The Problem, It’s How We Use Them
    • March 25, 2025
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    IBM contributes key open-source projects to Linux Foundation to advance AI community participation
    • March 22, 2025
  • 2
    Co-op mode: New partners driving the future of gaming with AI
    • March 22, 2025
  • 3
    Mitsubishi Motors Canada Launches AI-Powered “Intelligent Companion” to Transform the 2025 Outlander Buying Experience
    • March 10, 2025
  • PiPiPi 4
    The Unexpected Pi-Fect Deals This March 14
    • March 13, 2025
  • Nintendo Switch Deals on Amazon 5
    10 Physical Nintendo Switch Game Deals on MAR10 Day!
    • March 9, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.