How to Install PyCharm Community Python IDE and Create a Project

How to Install PyCharm Community Python IDE and Create a Project

Introduction.

I did a web search to find out “why python”? The results came back something like this…

Python is the fastest-growing programming language in the world. Its high-level, interpreted, and object-oriented architecture makes it ideal for all types of software solutions

As a long time, user of python, I can tell you it’s fun and easy to work with, and today seems to be gaining more popularity than ever. I have been asked many times to talk more about Python, so over the next while I’m going to be adding some blogs, projects etc. all focusing on programming in Python.

To keep things nice and simple, the IDE of choice will be the PyCharm Community Python IDE. There are many other IDE’s out there, so feel free to use which ever you like. But for this series I will be using PyCharm Community, simple because it’s giving the beginner everything needed in one place without any fuss. You can get the job done without the tool getting in your way too much.

There will be other tools used throughout the book (all free or open source) and we will talk about them as they are needed.

So, let’s get started…

You can download PyCharm Community

from here https://www.jetbrains.com/pycharm/download/#section=windows

For this exercise make sure you download the community edition.

Click the download button.

If you are using google chrome as your web browser, you will see the downloaded .exe file in the bottom left corner.

After you click download you will see this message, ignore it.

If the first link doesn’t work, then try the direct link, as in the above image.

However, we get here, the pycharm-community-2021.3.1.exe file will be downloaded to a folder on your computer (normally, for windows, it is the download folder).

NOTE: The version number of your file may be different.

Find the pycharm-community-2021.3.1.exe file on your computer and click to install. Or, you can simply click or double click the link at the bottom of your Chrome web browser.

You will be greeted with this, click next.

Keeping the default installation folder will be fine, unless you have a reason to change it.

I like to create a Desktop Shortcut, and I have found adding the bin folder to the PATH Variable is also a good idea.

Then click next.

Click Install, and it will all happen.

At this point PyCharm Community is installed and we need to reboot the computer to finalize the installation. Click Finish and let your computer restart.

See you in the next part…

Ok, now focus here people, you need to click the icon on the desktop to start the program. Sorry I get bored sometimes :).

The first time you run the program, you must agree to the user agreement, tick and continue.

Next and again only on your first use of the program, you need to decide on DATA SHARING with JetBrains. I have never heard of any harm coming from this and it does help them improve the IDE that you are using for free; so, you decide and click an option.

You should see the splash screen.

Then the Welcome to PyCharm screen, Click New Project.

1. Give your project a snappy name like ’mygreatepyapp’

2. Base interpreter – If you have Python installed select your interpreter here (Python version). If Python is not installed, skip this step and go to next step (3)

3. If Python is not installed or can’t be found, you will see two options appear at the bottom. Click which is applicable and…

4. Click Create.

See how smart the IDE is, it’s installing python for us. In this case python-3.9.7-amd64.exe. Your version could be different. Just leave things as they are and let the IDE carry on.

Now the IDE is creating a Virtual Environment, you know the one we didn’t have when we created the project.

Shared indexes will usually allow your IDE to load faster, so I would recommend the always download option.

Click an option.

Now watch the top of the screen…

When the green “RUN” main arrow lights up go ahead and click it. As this is a python terminal application, don’t expect bells and whistles, there is no fancy GUI.

When you run the code, you will see the terminal application write the “Hi, PyCharm” message. That shows everything worked as it should, yay!

Just to show things are working, put your mouse cursor at the start of the word ‘PyCharm’.

Now change it to something like ‘from al @ iotXplain’.

The PyCharm IDE has great auto save… when you type the changes it saves them automatically. But if like me you’re a bit OCD hitting the Ctrl key and s key (Ctrl+s) will Save-ALL.

RUN the code again and look at the terminal window.

Now fun as that was, all we did was just run the standard template of a terminal application, built into the PyCharm IDE. No writing of python code, so just not cool enough yet to call yourself a python coder.

So, make coffee and let’s write some code of our own.

Open PyCharm and Click Projects → New Project.

We are going to create a quick little game that allows you three chances to guess a random number to win or restart.

So, give the project a name, say, Guess_Number.

Make sure “create main.py” is ticked.

Click Create.

Wait until all the IDE activity creating your base project has finished.

On the left side of the IDE Right Click on main.py.

Select → Refactor > Rename

Enter New name for our file, I used “guess-number.py”

Click Refactor.

Now you should see guess-number.py file opened in the IDE.

Click on File → Select All

Then Click on File → Delete.

We are now going to type in our Guess_Number.Py code, into the ide.

You can copy and paste from the blog, remember python is sensitive to whitespace and indentation.

Source code for Guess_Number.Py

#========== start of source code

# Simple Guess a number game code

# Al McDivitt iotXplain

# https://www.iotxplain.com.au/

# Tribute is given to all the code I’ve seen over the years.

import random

print(“Welcome to the Number Guessing Game in Python!”)

number_range = [1, 10]

inp_msg = “Please guess a number between {} and {}: “.format(*number_range)

while True:

# Initialise the number to be guessed

number_to_guess = random.randint(*number_range)

# Initialise the number of tries the player has made

count_number_of_tries = 1

# Obtain their initial guess

guess = int(input(inp_msg))

while number_to_guess != guess:

print(“Sorry wrong number!”)

# Check to see they have not exceeded the maximum number of attempts if so break out of loop

if count_number_of_tries == 3:

break

elif guess < number_to_guess:

print(“Your guess was lower than the number.”)

else:

print(“Your guess was higher than the number.”)

# Obtain their next guess and increment number of attempts

guess = int(input(“Please guess again: “))

count_number_of_tries += 1

# Check to see if they did guess the correct number

if number_to_guess == guess:

print(“Well done you won!”)

print(“You took” + str(count_number_of_tries) + ” attempts to complete the game.”)

else:

print(“Sorry, you lose”)

print(“The number you needed to guess was ” + str(number_to_guess) + “.”)

if input(“Do you want another round? (y/n)”).lower() != “y”:

break

print(“Game Over.”)

#========== end of source code

When done you will have an IDE that looks something like this.

Now let’s play the game…

Run Guess-Number by clicking the green arrow in the top right corner of the IDE.

If the Terminal Window at the left-hand bottom of the IDE is as above, all is good left click into that window.

You can Play as long as you like.

That’s a wrap

We have gone over many small steps; I can assure you it is much easier to do than read or write about. Have a go you have absolutely nothing to lose,

Hope you have this enjoyed this little get started tutorial.

Cheer’s AL

iotXplain