Data Science: Setup Visual Studio Code with Python

azadkshitij

Azad Kshitij

Posted on October 19, 2022

Data Science: Setup Visual Studio Code with Python

Visual Studio Code

Visual Studio Code(VS Code) is one of the most famous code editor build by Microsoft which free and build on open source that runs everywhere. VS Code support almost every language and have support of many different extensions, with many themes. But usually most data scientists prefer to use Jupyter Notebook or Jupyter Lab for their data science projects as, visual studio support jupyter notebook files as well but there are many other features to choose VS Code over Jupyter Notebook.

Reasons to choose VS Code

  1. Better auto completion
    • We all know how bad the auto completion in in Jupyter Lab, we need to press ctrl+space to get suggestions. VS Code provides smart completions based on variable types, function definitions, and imported modules.
  2. Extensions
    • I know there are many extensions available in Jupyter Lab but are not enough and not that powerful. With VS Code's powerful extension system community have created many really impressive extensions and there are verified extensions provided by Microsoft.
  3. Debugging
    • Debugging is not that common thing for Data scientists but with the debugging features we can analyze intermediate variables to find problems in our code.
  4. Live share
    • you can collaboratively edit documents in real-time in VS Code, allowing you to do some pair programming, being apart.
  5. Support for all Common Files
    • As a data scientist we often need to open .csv, .json, .yaml etc. files and you know what VS Code support these out of box and you can install extensions to better handle there file types.

Enough talking about stuff lets start doing...

Get Started

Install VS Code

Go to the official download page for VS Code and follow usual installation steps. make sure to tick...

  • Add "Open with Code" action to Windows Explorer file context menu
  • Add 'Open with Code" action to Windows Explorer directory context menu this will allow us to open any folder directly in vscode. menu this will allow us to open any folder directly in vscode

After you will open Vscode for the first time it will look like this. Choose your proffered theme. Lets install some extensions...!

Vscode for the first time it will look like this

Install Extensions

  1. Click on the extension button on the left side bar.
  2. Search for python in the search bar.
  3. Click on the first extension you find and install it. (make sure it is provided by Microsoft).

vscode extension page

  1. This will install all the necessary extensions for python

This will install all the necessary extensions for python

Now you are all set to start working on your project, but there are some more setting that you can change to make it even more suitable as per your need. You can change layout (I prefer the side bar on the right as it doesn't change the view when I open and close it). You can change color theme if you want to my personal favorite is Atom One Dark Pro.

GitHub logo Binaryify / OneDark-Pro

Atom's iconic One Dark theme for Visual Studio Code

Atom's iconic One Dark theme, and one of the most installed themes for VS Code!

Preview in vscode.dev Version Installs

SPONSORS

A plugin for IDEA that records code CRUD operations, helping you identify potential issues in SQL and providing optimization suggestions.

一个记录代码 CRUD 操作的 IDEA 插件,帮助您识别潜在问题的SQL并提供优化建议。

SCREENSHOT

ScreenShot

Italic

ScreenShot

Default theme

ScreenShot

Flat theme

ScreenShot

Darker theme

ScreenShot

Retro theme

ScreenShot

Gnome theme

ScreenShot

Terminal

ScreenShot

Donation

If you like this extension, you could donate via PayPal It will encourage me to make this extension better and better!

Thanks List:

  • Andreas Georgiadis

Setting

ScreenShot

Built in themes

built-in themes

Notice

Setting only support default theme(One Dark Pro).

Markdown preview style

Markdown You can toggle whether to use markdown style in vscode setting (default use)

Suggest Editor Settings

 "editor.fontSize": 20,
 "editor.lineHeight": 30,
 "editor.fontFamily": "JetBrains Mono",

JetBrains Mono Download: https://www.jetbrains.com/lp/mono

Tweaks & theming

If you want to play around with new colors, use the setting workbench.colorCustomizations to customize the currently selected…

Settings

Now lets change some settings for productivity.

  1. Change font size as per your liking here are my font settings.
 "editor.fontSize": 22,
 "terminal.integrated.fontSize": 20,
 "editor.fontFamily": "Fira Code",
 "editor.fontWeight": "450",
 "editor.fontLigatures": true,
Enter fullscreen mode Exit fullscreen mode

Necessary fonts...

GitHub logo tonsky / FiraCode

Free monospaced font with programming ligatures

Fira Code: free monospaced font with programming ligatures

Fira Code

Read in Español | 简体中文 | 日本語

Problem

Programmers use a lot of symbols, often encoded with several characters. For the human brain, sequences like ->, <= or := are single logical tokens, even if they take two or three characters on the screen. Your eye spends a non-zero amount of energy to scan, parse and join multiple characters into a single logical one. Ideally, all programming languages should be designed with full-fledged Unicode symbols for operators, but that’s not the case yet.

Solution

Fira Code is a free monospaced font containing ligatures for common programming multi-character combinations. This is just a font rendering feature: underlying code remains ASCII-compatible. This helps to read and understand code faster. For some frequent sequences like .. or //, ligatures allow us to correct spacing.

Download & Install

Fira_Code_v6.2.zip - December 6, 2021 - 2.5 MB

Then:





  1. Jupyter Notebook
"jupyter.askForKernelRestart": false,
"jupyter.interactiveWindowMode": "perFile",
"jupyter.themeMatplotlibPlots": true,
"jupyter.textOutputLimit": 0,
"jupyter.sendSelectionToInteractiveWindow": true // <---- Very Important
"notebook.outline.showCodeCells": true,
"notebook.lineNumbers": "on",
"notebook.outputFontFamily": "CaskaydiaCove NF",
"notebook.cellToolbarVisibility": "hover",
"notebook.undoRedoPerCell": false,
Enter fullscreen mode Exit fullscreen mode

Now you are all set to change the future. In this article I talked about setting VS Code for data science in the future I will share how to properly use vscode to speed up your process and be more productive so make sure to follow the series and like to post if you have anything to say comment down below I'm new to blog writing so any type of feedback is appreciated Thanks.

References

  1. https://www.youtube.com/watch?v=ZaH7nEzgX7o&t=3s
  2. https://towardsdatascience.com/vs-code-for-data-science-aee82fe08bac
💖 💪 🙅 🚩
azadkshitij
Azad Kshitij

Posted on October 19, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related