Data Science: Setup Visual Studio Code with Python
Tags: python, datascience, vscode, jupyter
Published: 2022-10-19 03:47:47

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jv2vdhhyohvxx2p1yovy.png)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kp1kymvo4513cgao2bcd.png)


### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lk53ahhl35dzu4250a3.png)


4. This will install all the necessary extensions for python 

![This will install all the necessary extensions for python](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/md7xw9nciukkp0ti6icq.png)

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](https://github.com/Binaryify/OneDark-Pro).

{% embed https://github.com/Binaryify/OneDark-Pro %}

### Settings

Now lets change some settings for productivity. 
1. Change font size as per your liking here are my font settings. 
```json
 "editor.fontSize": 22,
 "terminal.integrated.fontSize": 20,
 "editor.fontFamily": "Fira Code",
 "editor.fontWeight": "450",
 "editor.fontLigatures": true,
```
Necessary fonts...
{% embed https://github.com/tonsky/FiraCode %}



2. Jupyter Notebook 
```json
"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,
```

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