Python: How to setup VS code

Just list of extensions needed for python to work well.

Posted on: 20 Oct 2023

Introduction

I want to standardize things a little bit with vscode. So I am writing this post.

Microsoft vscode

It’s Free, little bit open source, but owned by Bill Gates. So don’t get use it. So far I like it a lot because of plugins and most importantly it has in built git support.

Get started

  1. Install vscode
  2. Open a folder for your code
  3. Save the folder as workspace (File –> save as workspace) Workspace stores all your folders and settings in the file. So next time you can just open the workspace file.
  4. Download extensions, icon is on the left

Extensions

  1. Python extension pack

    This extension pack packages some of the most popular Python extensions.

    • Python - Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, Data Science (with Jupyter), PySpark and more.
    • Jinja - Jinja template language support for Visual Studio Code.
    • Django - Beautiful syntax and scoped snippets for perfectionists with deadlines.
    • Visual Studio IntelliCode - Provides AI-assisted productivity features for Python developers in Visual Studio Code with insights based on understanding your code combined with machine learning..
    • Python Environment Manager - Provides the ability to view and manage all of your Python environments & packages from a single place.
    • Python Docstring Generator - Quickly insert Python comment blocks with contextually inferred parameters for classes and methods based on multiple, selectable template patterns.
    • Python Indent - Correct python indentation in Visual Studio Code.
    • Jupyter - Provides Jupyter notebook support for Python language, used for data science, scientific computing and machine learning.
  2. Pylance: Fast, feature-rich language support for Python (update: they have added this part in the extension pack since this post was written.)
  3. Jupyter: Notebook for python
  4. CodeSnap: Lets you take screenshots of code
  5. Path Intellisense: Visual Studio Code plugin that autocompletes filenames.

To enable Jupyter style in python vscode (optional)

Enable this option settings > jupyter: send selection to interactive window

So Idea is that in vscode you can open the jupyter notebook and run like normal notebook, but what is even better that you get to run the python files like jupyter notebook

By turning on the option, you can open the python file, select the like of code and press shift + enter . This opens another window which is like jupyter notebook.

Install packages

Easy just use pip, it works and it is simple pip install blah

References

This guy did a video about it in context of data science, but I found his advice quite nice. https://www.youtube.com/watch?v=zulGMYg0v6U