PyCharm 2020.1 Help

Configuring folders within a content root

Within a content root, PyCharm can distinguish between the folders that contain source code, and the ones to be ignored while searching, parsing, watching and so on. To distinguish different types of folders, mark any folder below a content root as a source folder or as excluded.

  • Source roots the Source root icon contain the actual source files and resources. PyCharm uses the source roots as the starting point for resolving imports

  • Resource roots the Resources root icon are intended for resource files in your application (images, Style Sheets, and so on). By assigning a folder to this category, you tell PyCharm that files in it and in its subfolders can be referenced relative to this folder instead of specifying full paths to them.

  • Template roots the Template Folder icon contain templates for the various web projects.

  • Excluded roots the Excluded root icon contain files and folders ignored by PyCharm when indexing, searching, parsing, watching, and so on.

Marking directories

You can assign a folder to a category in two different ways:

To mark directories under the content root via the Project Structure

  1. Open the Project Structure settings.

  2. In the Projects pane of the Project Structure page, click the project you want to configure content roots for.

  3. In the Content roots pane of the Project Structure page, click the desired content root. The directories under this content root are displayed as a tree view.

  4. Select the directory you want to mark and do one of the following:

    • Click one of the icons on top to assign the desired status to this directory.

    • Choose the corresponding status command from the context menu of the directory.

    • Press Alt+ (for example, Alt+E for the excluded roots, Alt+R for resources, or Alt+S for the source roots ).

    Mark as COntent root

Mark directories in the Project tool window

  1. Right-click the desired directory in the Project tool window.

  2. From the context menu, point to Mark Directory As node.

  3. Choose Mark as <directory status>.

Mark directory in the Project tool window

Unmarking directories

To return a folder to its regular status, you need to unmark it.

  • In the Project Structure dialog:
    • Select the directory in the list of folders under the content root, and click Unmark source root:

      Unmark source root

    • Click the folder's status icon once more.

    • Choose the corresponding command from the context menu of the directory.

  • In the Project tool window, right-click the desired directory, point to Mark Directory As node, and then choose Unmark as <directory status>.

Last modified: 20 May 2020