With today’s October release of the Python extension, we’re excited to announce the support of native editing of Jupyter notebooks inside Visual Studio Code! You can now directly edit .ipynb files and get the interactivity of Jupyter notebooks with all of the power of 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. You can try out this experience today by downloading the latest version of the Python extension and creating/opening a Jupyter Notebook inside VS Code.
Since the initial release of our data science experience in VS Code, one of the top features that users have requested has been a more notebook-like layout to edit their Jupyter notebooks inside VS Code. In the rest of this post we’ll take a look at the new capabilities this offers.
Getting Started
Here’s how to get started with Jupyter in VS Code.
- If you don’t already have an existing Jupyter Notebook file, open the VS Code Command Palette with the shortcut CTRL + SHIFT + P (Windows) or Command + SHIFT + P (macOS), and run the “Python: Create Blank New Jupyter Notebook” command.
- If you already have a Jupyter Notebook file, it’s as simple as just opening that file in VS Code. It will automatically open with the new native Jupyter editor.
Once you have a Jupyter Notebook open, you can add new cells, write code in cells, run cells, and perform other notebook actions.
AI-Assisted Autocompletion
As you write code, IntelliSense will give you intelligent code complete suggestions right inside your code cells. You can further supercharge your editor experience by installing our IntelliCode extension to get AI-powered IntelliSense with smarter auto-complete suggestions based on your current code context.
Variable Explorer
Another benefit of using VS Code is that you can take advantage of the variable explorer and plot viewer by clicking the “Variables” button in the notebook toolbar. The variable explorer will help you keep track of the current state of your notebook variables at a glance, in real-time.
Now you can explore your datasets, filter your data, and even export plots! Gone are the days of having to type df.head() just to view your data.
Connecting To Remote Jupyter Servers
When a Jupyter notebook file is created or opened, VS Code automatically creates a Jupyter server for you locally by default. If you want to use a remote Jupyter server, it’s as simple as using the “Specify Jupyter server URI” command via the VS Code command palette, and entering in the server URI.
Exporting as Python Code
When you’re ready to turn experimentation into production-ready Python code, just simply press the “Convert and Save as Python File” button in the top toolbar and let the Python extension do all the work for you. You can then view that Python code in our existing Python Interactive window and keep on working with the awesome features of the Python extension to further make your code production-ready, such as the integrated debugger, refactoring, Visual Studio Live Share, and Git source control.
Debugging
VS Code supports debugging Jupyter Notebooks through using the “Exporting as Python Code” functionality outlined in the previous section. Once you have your code in the Python Interactive window, you can use VS Code’s integrated debugger to debug your code. We are working on bringing cell debugging into the Jupyter editor in a future release so stay tuned!
Try it out today!
You can check out the documentation for the full list of features available in the first release of the native Jupyter experience and learn to get started with Jupyter notebooks in VS Code. Also, if you have any suggestions or run across any issues, please file an issue in the Python extension GitHub page.
We’re excited for everyone to try out this new experience and have the Python extension in VS Code empower your notebook development!
Will it support Julia or R kernel ?
Thanks for the nice post. Can you make this feature available in Visual Studio 2019 too?
Very nice. But I have one request. How can I only clear output from a single cell instead of all cells or collapse a cell (output)?
Works well so far but not seeing how to open remote notebooks. Is this supported? Thanks
Can this be used to edit jupyter notebooks in other languages besides Python (e.g., Julia)?
Amazing to have this. However, I can’t import my .py modules (even when they are in the same directory). I opened a question on stackoverflow on this and no answers so far: https://stackoverflow.com/questions/59347912/import-py-with-ipynb-within-vscode
Every time I try to save it, it pops up asking me to overwrite the current file, then asks me if I am ok with overwriting it – this is extremely annoying.
I would love to switch over to using Jupyter in VS Code, but until this annoying issue is resolved, and auto-save functionality added, I just can’t.
I have problem running Jupyter, I’ll get:
Error: Jupyter server crashed. Unable to connect.
Error code from jupyter: 1
How to fix it?
Nice!
Any plans for Databricks notebooks support?
I extensively use Jupyterlab for my quick lookup using REST API calls. I need to use input() function. Are you planning any upgrade where it doesn’t throw an error?