This tutorial will show you how to download Visual Studio Code and set up a Jupyter Notebook on MacOS.
What is Visual Studio Code? What is a Jupyter Notebook?
How to Download Visual Studio Code
Visual Studio Code (VScode) is a free software that is used to write and edit code. We will use visual studio code to write Python code in a Jupyter Notebook. A Jupyter Notebook is a tool that allows you to write code and view outputs in a single document, allowing for an interactive coding process.
VScode can run either in the web browser or as a standalone app. To use VScode in the browser, nagivate to vscode.dev. It's best to use the Microsoft Edge browser to run vscode.dev.
- Start by going to https://code.visualstudio.com/ or by searching the web for Visual Studio Code. Once you get to the site, click the blue download button.
- In your downloads folder you will find a zipped visual studio code file. Double click on the file to unzip it.
- A new icon will appear of the Visual Studio Code logo. Double click to open the application.
- Once the application is open, let’s install some extensions to allow us to use Python and Jupyter notebooks in Visual Studio Code. On the left side of the application, look for the extensions icon and click on it.
- A new panel should open prompting you to search for extensions.
- In the search bar, type Python. Once you have found the extension, click the blue install button. It should say “installing” for a moment, and then it will be installed.
Tip: If you do not have Python installed on your computer, follow the Installing Python tutorial to get it set up.
- Now, let’s do the same thing to install the Jupyter extension. In the search bar type Jupyter, find the extension, and click the blue install button.
- Now that everything is installed, we can start a new Jupyter Notebook. If you already have a folder on your computer with data, you can get connected to it by selecting File > Open Folder… which will open a finder window where you can navigate to your project folder and select Open.
- You will know it opened successfully if the Explorer tab now displays the folder name and the files in it.
- Now that your folder is open, let’s create a Jupiter Notebook file. Hover over the name of your folder and some icons will appear next to it. Select the New File icon.
- Once selected, a new blank text entry box should appear under your folder name. Type in the name of your new file and make sure to give it the extention .ipynb. This will ensure that your new file is a Jupyter Notebook.
- Hit enter and your new Jupyter Notebook will be created. In the main panel, your new Jupyter Notebook should end up looking like this:
- Finally, we need to set the Python interpreter and Kernel to the correct environment. Start by pressing Cmd+Shift+P to open the Command Palette. Type Python: Select Interpreter and click on it.
- A new list will appear with your interpreter options. You can select whatever environment you would like, but I am going to select the one I set up to work on this data which I called ECOSTRESS.
Tip: If you do not have an environment set up on your computer, or do not know what an environment is, follow the Creating an Environment tutorial to get it set up.
Now your Visual Studio Code is set up for writing Python code for ECOSTRESS data!