What is the purpose of this article?
By reading this article, you will be able to:
- Download and install PyCharm
- Configure PyCharm.
- Create a new Python project in PyCharm
List of contents of this article:
Downloading and Installing PyCharm
Downloading and installing PyCharm is straightforward. It is just like installing any other application on your computer. I want to show these first steps here to explain the available Pycharm versions. To download PyCharm, you have to visit the JetBrains website.
Click on the download button. After that, you can choose between the paid and free versions of PyCharm. The professional version is paid, and the community version is free. I will download the professional version because I have a student account. My first tip is if you have a student account, you can have the paid version for free! I used the GitHub student developer pack to get access to it.
For me, the professional edition is useful because I have access to scientific tools. For example, while analyzing a dataset, you can see plots inside PyCharm and easily keep track of the variables you create. This feature reminds me of RStudio, so if you are used to RStudio you will feel right at home. On top of that, it has tight integration with Jupyter Notebook (and I love Jupyter Notebook! ❤️).
The other paid features are backend development support, remote development capabilities, and database support. You can check their editions comparison page for more information. The good news is that the intelligent coding assistance, the debugger, code inspections, version control integrations, and refactorings are available in the free version as well. Intelligent coding assistance means that PyCharm helps you to complete your code by showing the parameters a function takes or the available methods of a class, for example. After you download the image file, you copy it to your Applications folder.
After that, open PyCharm from the Applications folder. Go to the Applications folder, locate PyCharm, and right-click open it. If you are on Mac, you will receive an alert that says, “PyCharm is an app downloaded from the internet.” You can click Open anyway. As PyCharm launches, it will ask you if you would like to import settings from a Config or installation folder.
The first time PyCharm launches, it will offer you the chance to import older settings (from a previous PyCharm installation).
If you are installing PyCharm for the first time, you don’t need to import settings. I won’t import settings and opt for a fresh start. The next screen will ask you to customize PyCharm. The first question is to select a keymap scheme. Keymap scheme refers to keyboard shortcuts, check the different examples in the figure. I leave it as it is because I’ve never used PyCharm before, and it is updated for newer Mac OS versions.
I click on Next: UI Themes. On the following page, I opted for the dark ‘Darcula’ theme. Don’t be disappointed if you don’t like any of the themes right now. Later you can add a plugin that allows you to choose between several other beautiful options 😍 (hint: it’s a plugin called Material UI Theme). After you chose, click on Next: Launcher Script. A Launcher script adds a small terminal program that can launch PyCharm from your terminal in any given directory. What I mean is that it allows you to do the following:
In that line, I am launching PyCharm in the directory called ‘MyNewPythonApplication’ that is a sub-directory of ‘DeveloperProjects.’ If you like this feature, check the box. To continue, click on Next: Featured plugins.
On the next screen, Pycharm suggests popular plugins. That’s a personal choice. I didn’t install any of them. The configuration is almost ready, now click on Start using PyCharm.
Creating a new project in PyCharm
Now, the next step is to either open an old project (from a repository on your local machine or version control) or create a new project. Let’s suppose you want to start a new project. Then, click on + Create New Project.
Because I chose the professional version of PyCharm, I can select among several project options from the left sidebar. If you have the free version, you won’t have these options, so you can only open a new Pure Python project. You can create a new project in the same way, though. Chose the location (directory) where you want to save your project.
By clicking on Project Interpreter: New Virtualenv environment, you can choose the environment options for your new project. When you are coding in Python, you will probably make use of several libraries. The environment will hold all the libraries you will install for that project. There are two options 1) New environment or 2) Existing interpreter.
The new environment (first) option gives yet three possibilities, Virtualenv, Pipenv, or Conda. Virtualenv is the default option. Pipenv is newer, and it is supposed to have extra functionalities. To make use of Conda, you need to have installed the Anaconda or Miniconda on your machine. I use the default Virtualenv because it is the one I feel more comfortable. Besides, you can choose the Base interpreter (Python 3 in my case). Click on Create to continue.
Before you can start coding, PyCharm suggests a ‘Tip of the Day’ option with tricks on how to increase your productivity by using keyboard shortcuts. I find it useful, so I want to receive these tips for now. If you think you don’t need them, you can uncheck this option on the bottom left corner of the pop-up. After that, close the pop-up. Now you can create a new file by clicking Cmd + N (on Mac) or clicking on File > New > File or clicking File > New > Python File (from templates). If you chose the last option, PyCharm will create a file with the .py extension.
You can finally write your code! After you are ready, you can run your script by clicking Run on the main menu (the green arrow on the top right corner) or pressing Ctrl + Option + R on the keyboard. PyCharm offers several features to help you code. Now that the installation and configuration are complete, you can start getting accustomed to PyCharm and learning all the productivity hacks it offers! To read the full installation guide, click here.