Setting up PyCharm
Before writing actual code with PyCharm, you need to make a basic setup for PyCharm. You will be able to create a new project in your PyCharm and Python file by successfully follow the steps below.
Table of contents
- Check if Python is Working
- Create a New Project in PyCharm
- Create .py File into the Project
- Run Your .py File
Check if Python is Working
If you successfully installed Python, Git, and PyCharm, the first thing you need to do is to check if your Python program is working.
In Windows 10, you can check it using Command Prompt.
Press WIN (
) + R.
Type cmd in the Run window and press OK as the figure below shows.
If you were able to open Command Prompt, the next step is to execute the Python in it.
Type python in your Command Prompt like below (CASE INSENSITIVE).
If it is successful, you can see the current version of your Python, and after that, you will see three close angled brackets(
>>>
).The brackets indicate that you are currently using the Python interpreter.
STOP
If you failed to execute Python program in your Command Prompt, you MUST add Python to Windows PATH. To add Python to Windows PATH, please see Troubleshooting - Add Python to PATH.
Next, let’s print Hello World using Python.
Type print(“Hello World”) next to the angled brackets and press ENTER (CASE SENSITIVE).
You will see Hello World is printed on your screen.
GO
If you successfully followed the steps all the way here, it means your Python is perfectly working.
Type quit() to terminate Python in your Command Prompt.
Great! Your Python seems to be working perfectly!
Next, let’s create a new project in PyCharm.
Create a New Project in PyCharm
In this stage, you will be able to create a new project in your PyCharm.
Open your PyCharm and click the New Project button.
Click the arrow as is shown in the first red box and click the etc button (
...
) as the second red box shows.GO
If you can see an interpreter as the figure below, GO STRAIGHT TO STEP 5
Select System Interpreter from the left navigation bar and click the etc button (
...
).Then, find the path to python.exe file. It is usually in C:\Users\[YOUR_USER_NAME]\AppData\Local\Programs\Python\Python38\python.exe.
CAUTION
The number with Python (e.g., Python38) may vary depending on the Python version you installed.
When you have found your python.exe file, click the OK button.
Double check that you can see the interpreter correctly and press the OK button.
Press the Create button, then you get a new project in your PyCharm.
After you create a new project, you will see a window like the figure below.
Fantastic! You successfully created a new project in your PyCharm!
Next, let’s create a .py file in your project.
Create .py File into the Project
You will be able to create a .py file after completing the following steps.
Right-click the project directory, hover on New and click Python File sequentially.
Name your new .py file (HelloWorld in this example) and press ENTER.
Brilliant! You successfully created a .py file in your project!
You can also create multiple .py files in a project by repeating the steps above.
Finally, let’s run the .py file!
Run Your .py File
Running your .py file is one of the fundamental practices for Python beginners because you can check if your codes are working by running the codes.
You will be able to learn how to run a .py file by following the steps below.
Type your Python code like print(“Hello World”), right-click on your screen, and click Run [YOUR_FILE_NAME]
Check the result of the execution.
Congratulations!!! You successfully finished setting up your PyCharm.
Next, try to follow Linking to Github if you want to use PyCharm more efficiently.