Set Up PyCharm for Python: Install, First Project and First Run
Install PyCharm, create a Pure Python project, and understand the two words that confuse beginners: the interpreter (the cook) and .venv (the project's own shelf). Then run a file and read the exit code.
What you will learn
- Download and install PyCharm with the useful installer options
- Create a Pure Python project with its own .venv
- Explain what the Python interpreter and .venv are
- Run a file and read the Run window, including the exit code
Before you start
- A Windows, Mac or Linux computer
- Your First Python Program
You can write Python in any plain text editor. But then you still need something to run it, and something to help you find mistakes. An IDE (integrated development environment) puts all of that in one window, so you write, run and fix code in the same place.
The IDE we'll use is PyCharm, made for Python by JetBrains. The practice exercises in this course also come as PyCharm quizzes and code you can experiment with, so you learn an idea and practise it in the same window.
Download and install PyCharm
Open your browser, go to jetbrains.com/pycharm and click Download. On the download page, check your system is picked (Windows, Mac or Linux), then click the Download button. Newer versions may look a little different; the steps stay the same.
One product, core features free
PyCharm used to come in a free edition and a paid one. Now it's one product, so there's one thing to download. When you install it, a Pro trial starts and runs for 30 days. When that month ends, the Pro extras switch off, but the core features stay free and you can keep using them. You don't need to pay anything to get started.
The installer options
On Windows, open the file you downloaded and keep clicking Next until you reach a page of options. They're all worth ticking:
- Create a desktop shortcut, so you can open PyCharm quickly.
- Update the PATH, so you can start PyCharm from a terminal.
- The right-click option, so you can open any folder as a project.
- The
.pyassociation, so Python files open in PyCharm.
Click Install and give it a couple of minutes. On a Mac it's simpler: drag PyCharm into your Applications folder.
Start a new project
Open PyCharm. The first time it takes a moment, and your project list is empty, so click New Project. On the left is a list of project types. Pick Pure Python, the simplest one. Give it a name; mine is S01L03_Setup, but any name works.
Right under the name, PyCharm asks about an interpreter and a .venv. These two words stop a lot of beginners, so clear them up before you click anything.
What the Python interpreter is
Think about a recipe. It's only words on paper and can't cook anything by itself. To get a meal you need a cook who reads it from top to bottom and does each step.
Your .py file is the recipe; it's only text. The Python interpreter is the cook: a program that reads your file from top to bottom and carries it out. So when people say "install Python", they mean put the interpreter on your machine. Without it, PyCharm can't run your code.
A project's own .venv
A project may also need extras called libraries, the way a cook needs special ingredients. If all your projects share one shelf, a change made for one project can break another.
So each project gets its own shelf. That's .venv: a folder inside the project with a Python setup just for that project. Add a library there and it lands on this project's shelf; your other projects don't change. The name is short for virtual environment, and PyCharm makes it for you. If you want the full story, read Python virtual environments with venv.
Finish the new project
Back to the form. Keep the option that makes a .venv for this project. For the Python version, pick the newest Python 3 it offers. PyCharm may find a Python already on your machine; if not, it offers to download one, so there's nothing else to install.
Leave the welcome script option ticked, because that gives you a small file to run, and click Create. PyCharm gets Python, builds .venv and creates your file. How long that takes depends on your internet speed.
The parts of the window
- The Project tree on the left shows your files, including the
.venvfolder andmain.py. - The editor in the middle is where you write code. Your welcome script may have extra comments; mine is one line.
- The Run button, the green triangle, sits at the top right.
- The Run window along the bottom is where output appears.
- The bottom corner shows which interpreter the project uses. If it ever says no interpreter, click there to pick one.
Run your file
print("Hi, PyCharm")
Hi, PyCharm
Click Run. PyCharm hands main.py to the interpreter in .venv, the interpreter reads the line and carries it out, and the text comes out in the Run window.
Read the Run window
The Run window tells you three things, in order:
- The command: Python running
main.py. On your machine it's longer, with the full path to the interpreter in.venvand then your file. - Your output:
Hi, PyCharm. - A last line saying the process finished with exit code 0.
Exit code 0 means the program finished without a problem. Any other number means it stopped on one. Each time you run something, look at that last line.
Change it and run it again
Now make it yours. The line stays the same; only the words inside the quotes change. Here it is in a second file, new_message.py:
print("My first run, my own message")
My first run, my own message
You don't need to save, because PyCharm saves as you type. It's a new file, so right-click inside it and choose Run. Exit code 0 again. Change it, run it, read the output: you'll do this all through the course.
Common mistakes
- No interpreter selected. The file won't run; pick one in the bottom corner.
- Clicking the green Run button on a new file and running the old one. Right-click inside the new file and choose Run.
- Ignoring the last line. Exit code 0 is fine; anything else means something stopped.
Quick recap
| Word | What it is |
|---|---|
| IDE | one window to write, run and fix code |
| Interpreter | the program that reads your file and carries it out |
.venv | the project's own Python setup and libraries |
| Run window | command, output, exit code |
| Exit code 0 | finished without a problem |
Try it yourself
Change the message in main.py to your own words, run it again, and check that you get exit code 0. Then see what an error looks like in Run a Python file and read the error.
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
Python for AI: The Five Tools You Actually Need
The small part of Python that carries most AI code: dicts and JSON, typed functions with a dataclass, comprehensions and f-strings, environment variables for keys, and try/except for replies that are not JSON. Three standard-library scripts on four support tickets.
Thinking Like a Python Architect in an AI-First World
Coding is laying bricks; architecting is deciding how the pieces fit. A two-line average function shows why someone still has to understand the code an AI tool writes.
Your First Python Program: print, Comments, sep and end
Five tiny files: print and quotes, top-to-bottom order, # comments, several values with sep and end, and the SyntaxError one missing quote causes. Every output is from a real run.
Run a Python File and Read the Error: Tracebacks in Three Steps
Run a file two ways, then break it on purpose. A NameError, an IndentationError, a TypeError and a three-frame traceback across two files, all read the same way: last line, line number, fix.
