Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In a typical Python program, the PYTHONPATH
environment variable (or IRONPYTHONPATH
, and so on) provides the default search path for module files. The from <name> import...
or import <name>
statements instruct Python to search the specific locations for files that match the specified <name>
. The locations are searched in the following order:
Visual Studio ignores the search path environment variable, even when the variable is set for the entire system. The reason is because use of the variable raises questions that can't be easily answered, such as:
To assist developers, Visual Studio provides a way to specify search paths directly in both Python environments and projects. Code that you run or debug in Visual Studio receives search paths from the PYTHONPATH
environment variable and equivalent variable. By adding search paths, Visual Studio inspects the libraries in the specified locations and builds IntelliSense databases for the libraries as needed. (In Visual Studio 2017 version 15.5 and earlier, constructing the database can take some time depending on the number of libraries).
Visual Studio. To install the product, follow the steps in Install Visual Studio.
Python folders that you want to add to your search paths.
Follow these steps to add a Python folder to Visual Studio search paths:
In Solution Explorer, expand your Python project node, right-click Search Paths, and select Add Folder to Search Path:
In the dialog, browse to the location of the folder that you want to add to the recognized search paths.
Select the folder, and then choose Select folder.
After folders are added to the search paths, Visual Studio uses those paths for any environment associated with the project.
Note
If your environment is based on Python 3 and you attempt to add a search path to Python 2.7 modules, you might see errors.
You can add files with a .zip
or .egg
extension to your search paths with the Add Zip Archive to Search Path option. As with folders, the contents of these files are scanned and made available to IntelliSense.
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayTraining
Learning path
Remote development with Visual Studio Code - Training
Remote development provides benefits like consistent environments, the ability to use more powerful hardware, and the flexibility to develop on different platforms without impacting your local machine. Visual Studio Code provides tools for various remote development setups, such as using a container, a remote machine, or the Windows Subsystem for Linux (WSL). In this path, you'll learn about the different remote development offerings available in Visual Studio Code and practice using them.