PyCharm
 
Get PyCharm

Auto import

Last modified: 11 October 2024

When you reference a class that has not been imported, PyCharm helps you locate this file and add it to the list of imports. You can import a single class or an entire package, depending on your settings.

The import statement is added to the imports section, but the caret does not move from the current position, and your current editing session does not suspend. This feature is known as the Import Assistant. Using Import Assistant is the preferred way to handle imports in PyCharm because import optimizations are not supported via command line.

The same possibility applies to XML files. When you type a tag with an unbound namespace, the import assistant suggests creating a namespace and offers a list of appropriate choices.

When you complete a ES6 symbol or a CommonJS module, PyCharm either decides on the style of the import statement itself or displays a popup where you can choose the style you need. Learn more from Auto-import in JavaScript.