Skip to main content

Introduction to the PyCharm IDE

Creating Your First Project in PyCharm

When you first use PyCharm, you'll be welcomed by its startup screen.

PyCharm Startup Screen

To create a blank Python project, click on "New project."

Create New Project

PyCharm will now prompt you to configure the Python project:

Configure Python Project

In this example, the project files will reside in my /home/dolica/PyCharmProjects/first-pycharm-project directory. However, you can choose a location that suits your needs.

For the virtual environment, select Conda. PyCharm automatically makes the virtual environment's name match the project name, and this is something we wish to keep as it makes things less confusing. The setup page also asks if you want to create a main.py welcome script; for this project, you should keep this option checked. This will have PyCharm create a basic Python file for you instead of just preparing a blank directory.

Once the setup is complete, click "Create."

The PyCharm Interface

After creating your project, you'll land in the main PyCharm interface.

PyCharm Interface

Here's a quick overview:

  • Project Tool Window: This displays the files comprising your Python project. Right now, there's only one file, main.py, but more complex projects will have multiple files and folders.

  • Menu: Clicking here opens the PyCharm menu.

  • Editor: This is where you write code. The tab bar at the top lets you switch between different files, though currently, we have only one, main.py.

  • Environment: This shows the environment used to run your Python files for this project, matching the Mamba settings you selected when creating the project.

  • Breakpoint: Breakpoints are handy for pausing program execution, especially when debugging code to find issues.

  • Run & Debug: The run button (play symbol) runs your code and displays the output in the console. The debug button (bug symbol) runs the program in debugging mode, pausing at breakpoints.

Hi, PyCharm

Now you should see the PyCharm editor with our main.py file open. You'll notice a print_hi command created by PyCharm. You'll learn more about how these commands work and how to create your own later. For now, let's run this file:

Run main.py

This opens the "Run" panel at the bottom of the window, displaying the output:

Run Panel Output

The text "Process finished with exit code 0" indicates that the program ran without errors. Our main.py code is designed to display "Hi, PyCharm," and it has executed correctly.