This guide will walk you through the process of setting up Visual Studio Code (VSCode) for Python development with a focus on machine learning.
VSCode provides a rich ecosystem of extensions that can make Python development smoother and more efficient. Here are some key extensions to install:
ms-python.python
) - Offers Python language support including IntelliSense, linting, debugging, code formatting, etc.ms-toolsai.jupyter
) - Provides Jupyter notebook support, interactive programming and computing.LittleFoxTeam.vscode-python-test-adapter
) - Supports unit testing in Python.To install an extension, follow these steps:
Ctrl+Shift+X
to open the Extensions view.VSCode needs to be configured to use the correct Python interpreter for your project. To do this:
You can also configure the interpreter used by VSCode by modifying the .vscode/settings.json
file in your workspace:
{
"python.defaultInterpreterPath": "/path/to/your/python"
}
NOTE: When setting the interpreter via the UI, VSCode saves your selection in a workspace-specific sqlite settings file under ~/.config/Code/User/workspaceStorage/
. That is intended to be a way to share settings but is ignored when you select the interpreter via the UI.
To set up debugging in Python with VSCode, see the Troubleshooting Guide.
With the Jupyter extension installed, you can create a new Jupyter notebook by clicking on the new file button in the Explorer view and giving the file a .ipynb extension.
To enable pair programming, install the “Live Share” extension. This allows you to share your workspace with others for collaborative work.
With these steps, you will have a robust and efficient Python development environment set up in VSCode.