Jupyter Notebooks are documents that contain a mix of live code (Python, R, Julia, JavaScript, and more), visualizations, and narrative text (Markdown). They're useful for breaking down concepts in a story telling form, where you can give some context and show the code below along with interactive visualizations. The Notebook API allows Visual Studio Code extensions to open files as notebooks, execute notebook code cells, and render notebook outputs in a variety of rich and interactive formats. You may know of popular notebook interfaces like Jupyter Notebook or Google Colab β the Notebook API allows for similar experiences inside Visual Studio Code. Within the Notebook Editor window, double-click any plot to open it in the viewer, or select the plot viewer button on the upper left corner of the plot (visible on hover). Read more about using Jupyter in Visual Studio Code.
Jupyter Notebook quick start. The Python extension and the Jupyter extension work together to give you a great Notebook experience in VS Code. Open or create a Jupyter Notebook file (.ipynb) and start coding in our Notebook Editor! For more information you can: Follow our Python tutorial with step-by-step instructions for building a simple app. Jupyter: Enter the url of local/remote Jupyter Notebook Select existing kernels from the drop-down list, or start a new kernel Select language for the kernel from drop-down list: e.g., 'Python 3'.
A Visual Studio Codeextension with rich support for the Python language (for all actively supported versions of the language: >=3.6), including features such as IntelliSense, linting, debugging, code navigation, code formatting, refactoring, variable explorer, test explorer, and more!
Additionally, the Python extension gives you an optimal and feature-rich experience for working with Jupyter notebooks through the Jupyter extension.
Select your Python interpreter by clicking on the status bar
Configure the debugger through the Debug Activity Bar
Configure tests by running the Configure Tests
command
The Python extension and the Jupyter extension work together to give you a great Notebook experience in VS Code.
Open or create a Jupyter Notebook file (.ipynb) and start coding in our Notebook Editor!
For more information you can:
Open the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux) and type in one of the following commands:
Command | Description |
---|---|
Python: Select Interpreter | Switch between Python interpreters, versions, and environments. |
Python: Start REPL | Start an interactive Python REPL using the selected interpreter in the VS Code terminal. |
Python: Run Python File in Terminal | Runs the active Python file in the VS Code terminal. You can also run a Python file by right-clicking on the file and selecting Run Python File in Terminal . |
Python: Select Linter | Switch from Pylint to Flake8 or other supported linters. |
Format Document | Formats code using the provided formatter in the settings.json file. |
Python: Configure Tests | Select a test framework and configure it to display the Test Explorer. |
To see all available Python commands, open the Command Palette and type Python
. For Jupyter extension commands, just type Jupyter
.
Learn more about the rich features of the Python extension:
IntelliSense: Edit your code with auto-completion, code navigation, syntax checking and more
Linting: Get additional code analysis with Pylint, Flake8 and more
Code formatting: Format your code with black, autopep or yapf
Debugging: Debug your Python scripts, web apps, remote or multi-threaded processes
Testing: Run and debug tests through the Test Explorer with unittest, pytest or nose
Jupyter Notebooks: Create and edit Jupyter Notebooks, add and run code cells, render plots, visualize variables through the variable explorer, visualize dataframes with the data viewer, and more
Environments: Automatically activate and switch between virtualenv, venv, pipenv, conda and pyenv environments
Refactoring: Restructure your Python code with variable extraction, method extraction and import sorting
The extension is available in multiple languages: de
, en
, es
, fa
, fr
, it
, ja
, ko-kr
, nl
, pl
, pt-br
, ru
, tr
, zh-cn
, zh-tw
The Microsoft Python Extension for Visual Studio Code collects usagedata and sends it to Microsoft to help improve our products andservices. Read ourprivacy statement tolearn more. This extension respects the telemetry.enableTelemetry
setting which you can learn more about athttps://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting.
Few days back, I decided to setup development environment for deep learning on my Windows 10 laptop. In this article, I would share my experience in setting up a system typically for Data Science developers. Although I used Windows 10 but the steps will be same for Linux and Mac OS.
Being a developer, need IDE for coding and not fan of browser based editor. Jupyter Notebook is favourite tool for data scientist and we canβt skip that in case of data science. Fortunately, VS Code supports Jupyter notebook. You can now directly edit .ipynb files and get the interactivity of Jupyter notebooks with all of the power of VS Code. We will go through it.
1. Install Python
2. Install TensorFlow 2.0
3. Install Jupyter Notebook
4. Setup VS Code
5. Testing Environment
6. Virtual Environment (Optional)
Download Python 3.7.6 from www.python.org(Currently, Tensorflow doesnβt support Python 3.8). I would suggest to install it with βcustomize installationβ option and allow all users.
After installation, check the Python version on terminal. If there are multiple versions of python installed in the machine then change PATH in environment variable to the installed version and restart terminal to check version.
TensorFlow is open source deep learning framework by Google, helps us to build and design Deep Learning models.
For simplicity, we will install CPU version of TensorFlow.
It will install all supportive extensions like numpy β¦etc.
Note: Install the GPU version of TensorFlow only if you have an Nvidia GPU. It is good and recommended for better performance. It needs to Install/Update nvidia driver, cuda toolkit, cuDNN and then run following command to install
For more information, check out the official guide here.
The next is to install Matplotlib- a Python library for 2D plotting and can work together with NumPy.
Jupyter Notebook is web based interactive environment for writing the code, creating & sharing files and doing visualizations as well.
run following command to install it:
Start the notebook server from the command line:
You should see the notebook open in your browser.
If you want to specify port:
Download and install VS Code if not already installed.
Install the following VS Code extension from the marketplace.
Note: Make sure you have installed the latest version of the extension.
First time, open the VS Code Command Palette with the shortcut CTRL + SHIFT + P (Windows) or Command + SHIFT + P (macOS) in VSCode and select βPython: Select Interpreterβ command. It will display all installed versions. Select the appropriate python environment where Jupyter notebook is installed.
To create new Jupyter notebook, open VS Code Command Palette again and run the βPython: Create Blank New Jupyter Notebookβ command.
Why VS Code?
β You can manage source control, open multiple files, and leverage productivity features like IntelliSense, Git integration, and multi-file management, offering a brand-new way for data scientists and developers to experiment and work with data efficiently.
β Variable Explorer will help you keep track of the current state of your notebook variables at a glance, in real-time.
β You can export as Python code and do debugging and other operation like do in regular python application
Now, it is time to test the environment.
Create a new Jupyter book in VS Code and run following code to test :
The output should be following:
a) As we are going to use same environment for all so installed TensorFlow, Jupyter Notebook in global Python environment. If you want to create a separate environment for this, you can create a virtual environment by running following command:
It will create .venv directory at specified path.
b) To activate python virutal environment
In VS Code:
In Command Palette CTRL + SHIFT + P, Run βPython: Create Terminalβ. It will open and activate the terminal in selected Python environment.
c) Now install the TensorFlow, Jupyter notebook β¦etc in the activated environment.
In this tutorial, we saw
β how to set up a Python Deep Learning development environment using TensorFlow 2.0, Jupyter Notebook and VS Code.
β how Python extension in VS Code empowers notebook development in developer way.
If you face any problems, then feel free to share them in the comment section.
Enjoy Deep Learning !!