PyCharm is a dedicated Python Integrated Development Environment (IDE) providing a wide range of essential tools for Python developers, tightly integrated together to create a convenient environment for productive Python, web, and data science development.
PyCharm is available in three editions: Professional, Community, and Edu. The Community and Edu editions are open-source projects and they are free, but they have less features. PyCharm Edu provides courses and helps you learn programming with Python. The Professional edition is commercial, and provides an outstanding set of tools and features. For details, see the editions comparison matrix.
To start developing in Python with PyCharm you need to download and install Python from python.org depending on your platform.
PyCharm supports the following versions of Python:
Python 2: version 2.7
Python 3: from the version 3.5 up to the version 3.8
PyCharm is a cross-platform IDE that works on Windows, macOS, and Linux. Check the system requirements:
|RAM||4 GB of free RAM||8 GB of total system RAM|
|Disk space||2.5 GB and another 1 GB for caches||SSD drive with at least 5 GB of free space|
Officially released 64-bit versions of the following:
Pre-release versions are not supported.
|Latest 64-bit version of Windows, macOS, or Linux (for example, Debian, Ubuntu, or RHEL)|
Step 1. Open/Create a project in PyCharm
Why do I need a project?
Everything you do in PyCharm, you do within the context of a project. It serves as a basis for coding assistance, bulk refactoring, coding style consistency, and so on.
You have three options to start working on a project inside the IDE:
Open an existing project
Begin by opening one of your existing projects stored on your computer. You can select one in the list of the recent projects on the Welcome screen or click Open:
Otherwise, you can create a project for your existing source files. Select the command Open on the menu, and specify the directory where the sources exist. PyCharm will then create a project from your sources for you. Refer to the section Importing Project from Existing Source Code for details.
Check out an existing project from Version Control
You can also download sources from a VCS storage or repository. Choose Git (GitHub), Mercurial, Subversion, Perforce (supported in Professional edition only), and then enter your credentials to access the storage.
Then, enter a path to the sources and clone the repository to the local host:
Refer to the section Version control for details.
Create a project from scratch
To create a project, do one of the following:
From the main menu, choose
On the Welcome screen, click Create New Project
New Project dialog opens.
In the New Project dialog, specify the project name and its location. The dialog may differ depending on the PyCharm edition.
Next, click to expand the Project Interpreter node, and select the new environment or existing interpreter, by clicking the corresponding radio-button.
The following steps depend on your choice:
Next, specify the Location and Base interpreter of the new virtual environment. If necessary, click the Inherit global site-packages and Make available to all projects check boxes.
When configuring the base interpreter, you need to specify the path to the Python executable. If PyCharm detects no Python on your machine, it provides two options: to download the latest Python versions from python.org or to specify a path to the Python executable (in case of non-standard installation).
Existing interpreter: if this option has been selected, choose the desired interpreter from the list, or (if the desired interpreter is not found), click and choose the interpreter. See Configure a Python interpreter for details.
The new project will be created:
By this time, the editor area is grey as you don't have any files in your project. Create a Python file to start coding your script.
Creating a Python file
Select the project root in the Project tool window, then select from the main menu or press Alt+Insert.
Choose the option Python file from the popup, and then type the new filename.
PyCharm creates a new Python file and opens it for editing.
Configure project interpreter
When creating a new project you need to add and configure a project interpreter.
When you configure a project Python interpreter, you need to specify the path to the Python executable in your system. So, before configuring a project interpreter, you need to ensure that you've downloaded Python and installed it in your system and you're aware of a path to it. You can create several project interpreters based on the same Python executable. This is helpful when you need to create different virtual environments for developing different types of applications. For example, you can create one virtual environment based on Python 3.6 to develop Django applications and another virtual environment based on the same Python 3.6 to work with scientific libraries.
In the Settings/Preferences dialog Ctrl+Alt+S, click Project Interpreter, then click , and choose . Depending on your project specifics you can select:
Step 2. Look around
When you launch PyCharm for the very first time, or when there are no open projects, you see the Welcome screen. It gives you the main entry points into the IDE: creating or opening a project, checking out a project from version control, viewing documentation, and configuring the IDE.
When a project is opened, you see the main window divided into several logical areas. Let’s take a moment to see the key UI elements here:
Project tool window on the left side displays your project files.
Editor on the right side, where you actually write your code. It has tabs for easy navigation between open files.
Navigation bar above the editor additionally allows you to quickly run and debug your application as well as do the basic VCS actions.
Gutter, the vertical stripe next to the editor, shows the breakpoints you have, and provides a convenient way to navigate through the code hierarchy like going to definition/declaration. It also shows line numbers and per-line VCS history.
Scrollbar, on the right side of the editor. PyCharm constantly monitors the quality of your code and always shows the results of its code inspections in the gutter: errors, warnings, and so on. The indicator in the top right-hand corner shows the overall status of code inspections for the entire file.
Tool windows are specialized windows attached to the bottom and sides of the workspace and provide access to typical tasks such as project management, source code search and navigation, integration with version control systems, and so on.
The status bar indicates the status of your project and the entire IDE, and shows various warnings and information messages like file encoding, line separator, inspection profile, and so on. It also provides quick access to the project interpreter settings.
Also, in the bottom-left corner of the PyCharm window, in the Status bar, you see the button or . This button toggles the showing of the tool window bars. If you hover your mouse pointer over this button, the list of the currently available tool windows show up:
Step 3. Customize your environment
Feel free to tweak the IDE so it suits your needs perfectly and is as helpful and comfortable as it can be. Go to File | Settings ( for macOS users) to see the list of available customization options.
The first thing to fine-tune is the general "look and feel." Go to File | Settings | Appearance and Behavior | Appearance ( for macOS users) to select the IDE theme: the light themes or Darcula if you prefer a darker setting.
The many pages available under File | Settings | Editor ( for macOS users) help you adjust every aspect of the editor’s behavior. A lot of options are available here, from general settings (like Drag'n'Drop enabling, scrolling configuration, and so on.), to color configuration for each available language and use case, to tabs and code folding settings, to code completion behavior and even postfix templates.
Refer to the section Configuring PyCharm settings for details.
Refer to Configuring code style and Code Quality Assistance Tips and Tricks, or How to Make Your Code Look Pretty? for details.
PyCharm uses the keyboard-centric approach, meaning that nearly all actions possible in the IDE are mapped to keyboard shortcuts.
The set of keyboard shortcuts you work with is one of your most intimate habits — your fingers "remember" certain combinations of keys, and changing this habit is easier said than done. PyCharm supplies you with a default keymap (choose from the main menu) making your coding really productive and convenient. However, you can always change it going to File | Settings | Keymap ( for macOS users).
There are also some pre-defined keymaps (like Emacs, Visual Studio, Eclipse, NetBeans and so on), and you can also create your own keymap based on an existing one.
If you feel most productive with vi/Vim, an emulation mode will give you the best of both worlds. Enable the IdeaVim plugin in the IDE and select the vim keymap.
Refer to the section Configuring keyboard shortcuts for details.
Step 4. Code with smart assistance
PyCharm takes care of the routine so that you can focus on the important. Use the following coding capabilities to create error-free applications without wasting precious time.
Code completion is a great time-saver, regardless of the type of file you’re working with.
Basic completion works as you type and completes any name instantly.
Smart type completion analyzes the context you’re currently working in and offers more accurate suggestions based on that analysis.
PyCharm keeps an eye on what you are currently doing and makes smart suggestions, called intention actions, to save more of your time. Indicated with a lightbulb, intention actions let you apply automatic changes to code that is correct (in contrast to code inspections that provides quick-fixes for code that may be incorrect). Did you forget to add some parameters and field initializers to the constructor? Not a problem with PyCharm. Click the lightbulb (or press Alt+Enter) and select one of the suggested options:
The full list of available intention actions can be found inor for macOS users.
Step 5. Keep your code neat
PyCharm monitors your code and tries to keep it accurate and clean. It detects potential errors and problems and suggests quick-fixes for them.
Every time the IDE finds unused code, an endless loop, and many other things that likely require your attention, you’ll see a lightbulb. Click it, or press Alt+Enter, to apply a fix.
The complete list of available inspections can be found under (or for macOS users). Disable some of them, or enable others, plus adjust the severity of each inspection. You decide whether it should be considered an error or just a warning.
Step 6. Generate some code
Writing code can be a lot easier and quicker when you use the code generation options available in PyCharm. The menu Alt+Insert will help you with creating symbols from usage, as well as suggest overriding/implementing some functions:
Use live templates (choose Settings/Preferences dialog Ctrl+Alt+S (Settings | Editor | Live templates or if you are a macOS user).or press Ctrl+J) to produce the entire code constructs. You can explore the available ready-to-use live templates In the
If you see that you are lacking something especially important for your development, extend this set of templates with your own. Also, consider quickly surrounding your code with complete constructs (choose or press Ctrl+Alt+T. For example, select an
and you will get:
Step 7. Find your way through
When your project is big, or when you have to work with someone else’s code, it’s vital to be able to quickly find what you are looking for and dig into the code. This is why PyCharm comes with a set of navigation and search features that help you find your way through any code no matter how tangled it is.
Search for usages
To find where a particular symbol is used, PyCharm suggests full-scale search via Find Usages Alt+F7:
You can tell a lot just looking at your File Structure, with its imports or call hierarchies:
Also, you can navigate to:
The icons in the left-hand gutter can also help you with navigation:
Navigate through the timeline
To go through the history of changes, try using Back/Forward navigation (Ctrl+Alt+Left/ Ctrl+Alt+Right) and/or go to last edit location Ctrl+Shift+Backspace.
If you have a general idea of what you're looking for, you can always locate the corresponding element using one of the existing navigation features. But what if you really want to look for something in every nook and cranny? The answer is to use Search Everywhere!
To try it, click the magnifying glass button in the upper right-hand corner of the window, or invoke it with Double Shift (press Shift twice).
Step 8. Run, debug and test
Now when you’ve played with the code and discovered what you can do with it, it’s time to run, debug and test your app.
The easiest way to run an application is to right-click its background in the editor, and then choosefrom the context menu:
If your Python script contains the
__main__ clause, then you can click the button in the gutter, and then choose the desired command.
When you perform run, debug, or test operations with PyCharm, you always start a process based on one of the existing run/debug configurations, using its parameters.
When you run your application for the very first time, PyCharm automatically creates the temporary Run/Debug configuration. You can modify it to specify or alter the default parameters and save it as a permanent Run/Debug configuration.
Open the Run/Debug Configurations dialog to see all the available options. For example, if you want to run some script before/after the build phase, you can do this easily by creating an external tool:
To run a configuration, press Shift+F10.
Does your application stumble on a runtime error? To find out what’s causing it, you will have to do some debugging. PyCharm supports the debugger on all platforms.
Debugging starts with placing breakpoints at which program execution will be suspended, so you can explore program data. Just click the gutter of the line where you want the breakpoint to appear.
To start debugging your application, press Shift+F9. Then go through the program execution step by step (see the available options in the Debug tool window), evaluate any arbitrary expression, add watches and manually set values for the variables.menu or in the
Refer to the section Debugging for details.
It is a good idea to test your applications, and PyCharm helps doing it as simple as possible.
With PyCharm, you can:
- Create tests
Create special testing run/debug configurations.
Run and debug tests right from the IDE, using the testing run/debug configurations.
And, finally, the most important thing - you can explore test results in the test runner tab of the Run tool window:
To learn about the numbers, read the Test Runner tab section.
PyCharm supports all the major Python testing frameworks:
For each of these frameworks, PyCharm provides its own run/debug configuration.
Step 9. Keep your source code under Version Control
If you are keeping your source code under version control, you will be glad to know that PyCharm integrates with many popular version control systems: Git (or GitHub), Mercurial, Perforce (supported in Professional edition only), Subversion. To specify credentials and any settings specific to a particular VCS, go to (or if you are a macOS user).
The VCS menu gives you a clue about what commands are available. For example, you can see the changes you’ve made, commit them, create changelists and much more from the Local Changes view:(or just press Alt+9). Also find some VCS basic commands in the Navigation bar above the editor:
Refer to the section Version control for details.
In addition to traditional version control, you can use the local history. With Local History, PyCharm automatically tracks changes you make to the source code, the results of refactoring, and so on
Local history is always enabled. To view it for a file or a folder, bring up Local History by selecting . Here you can review the changes, revert them or create a patch.
Step 10. Remote development
With PyCharm, one can use project interpreters located remotely. In the Settings/Preferences dialog Ctrl+Alt+S, choose the page Project Interpreter , then click ), and select Add :
You can add and configure the following remote interpreters:
First, you can deploy your local applications to some remote server. To learn about deployment servers, refer to the section Configuring Synchronization with a Web Server. Having deployed an application, you can run, debug and test it remotely. PyCharm also helps you compare local and remote folders, and synchronize the local copy with that deployed on the server.
Step 11. Databases
As you might have noticed already, creating projects of the various types (Django, for example) requires a data source. It is also quite possible that you inject SQL statements into your source code.
PyCharm does not enable you to create databases, but provides facilities to manage and query them. Once you are granted access to a certain database, you can configure one or more data sources within PyCharm that reflect the structure of the database and store the database access credentials. Based on this information, PyCharm establishes connection to the database and provides the ability to retrieve or change information contained therein.
Access to the databases is provided by the Database tool window ( ). This tool window allows you to work with the databases. It lets you view and modify data structures in your databases, and perform other associated tasks.
See Database tools and SQL for details.
Step 12. Data Science Tools
With PyCharm, you can analyze and visualize various scientific and statistical data. Jupyter Notebook integration enables editing, executing, and debugging notebook source code and examining execution outputs including stream data, images, and other media.
With the R plugin installed in PyCharm, you can perform various statistical computing using R language and use coding assistance, visual debugging, smart running and preview tools, and other popular IDE features.
That’s it! Go ahead and develop with pleasure!
We hope this brief overview of essential PyCharm features will give you a quick start. There are many important features that make a developer’s life easier and more fun, and the source code neater and cleaner. Take these first few steps now, and then dig deeper when you feel the time is right. Enjoy PyCharm!
With any questions visit our Discussion Forum, twitter and blog, where you can find news, updates, and useful tips and tricks. Also, don't hesitate to report any problems to our support team) or the PyCharm issue tracker.