Skip to main content

Introduction to the PyCharm IDE

Creating Your First Project in PyCharm

When you first use PyCharmPyCharm, you'll be greetedwelcomed by its startup screen.

MicrosoftTeams-image.pngPyCharm Startup Screen

To create a blank Python projectproject, weclick can do this by clikingon "New Project" as shown below:project."

Create New Project

Now PyCharm askswill usnow prompt you to configure the Python project.project:

Configure Python Project

In this exampleexample, the project files will bereside in my /home/dolica/PyCharmProjects/first-pycharm-project directorydirectory. butHowever, you'reyou free tocan choose whatevera location that suits you.your needs.

For the virtual environment you shouldenvironment, select Conda. AsPyCharm automatically makes the virtual environment's name match the project name, and this is something we mentioned earlier, Mamba is . At this point PyCharm should automatically find the folder in which Mamba environments are created. In orderwish to avoidkeep confusionas laterit on,makes it'sthings aless goodconfusing. idea to make sure that the name of your virtual environment should matches the name of your project.

The setup page also asks us if weyou wishwant to create a main.py welcome script.script; Forfor this project, weyou should keep this option checked. This will keep the box ticked. This just means thathave PyCharm will create a basic Python file for usyou ratherinstead thanof simplyjust preparing a blank directory.

NowOnce thatthe setup is complete, we can click "Create."

The PyCharm Interface

NowAfter thatcreating we'veyour createdproject, ouryou'll firstland project we will arrive atin the main PyCharm interface.

MicrosoftTeams-image (1).pngPyCharm 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. HereYou'll we havenotice a print_hi command that has been created by PyCharm. Later on, you'You'll learn a bit more about how these thingscommands work and how you canto create your own commands.later. NowFor wenow, canlet's run this file by clicking the green "play" button in the top right or by using the Shift + F10 command.file:

Run main.py

This now causesopens the "Run" panel to open at the bottom of the window.window, It showsdisplaying the output of our code.output:

Run Panel Output

The text "Process finished with exit code 0" indicates that the program didn'tran crash.

without

Whileerrors. it may not be clear to you right now, the code in ourOur main.py filecode is supposeddesigned to show the textdisplay "Hi, Pycharm".PyCharm," So we can clearly see that it's done whatand it washas supposedexecuted to do.correctly.