Tips & Tricks

More languages, more power: Python support

Hi,

CLion is known to be a cross-platform IDE for C and C++. However, the first CLion 1.5 EAP build brought the Swift support to CLion and made IntelliJ-based Swift IDE on Linux possible. Recent CLion EAP build added support for Python. Let’s take a look at the features.

Initial setup

Getting started with Python in CLion is way more easier than starting with Swift, since the plugin is already bundled into the IDE and is on by default. All you need is to install Python SDK and point CLion to the Python interpreter for your project:
python_interpreter
Since CLion is using CMake project model as a basis, you still need to have a proper CMake project, and then can mix Python and C/C++.

Rem. In case of working with Python in CLion due to PY-18231 and PY-18221 we do recommend to set run.processes.with.pty to false in CLion’s registry:

  • in Find Action dialog (Shift+Ctrl+A on Linux/Windows, ⇧⌘A on OS X) type Registry,
  • in the registry type run.processes.with.pty to find the parameter,
  • untick the parameter there.

This is necessary for correct Python console and Python run/debug functioning.

We also observed several problems with debugger on Windows, when using Python from Cygwin. So better install it from here.

Features

The feature set corresponds to the PyCharm IDE Community Edition and includes all the basic and essential Python editing features, as well as running, debugging and testing.

You may notice quite a lot of new settings available if filter them typing ‘python’:
python_settings

Python plugin in CLion provides:

  • Python code parsing and highlighting. Colors & Fonts settings will help you to configure your favourite scheme.
  • Python code built-in code formatter together with the separate set of Python code style settings that support you code style preferences.
  • Code completion, file structure view and various navigation actions:
    python_goto_class
  • Find Usages in Python code.
  • Live Templates for generating widely-used code samples with ease:
    python_live_templates
  • Refactorings, including Rename, Change Signature, Extract Variable/Parameter/Constant/etc. and more.
  • A huge list of code intentions and inspections with quick fixes to make your code better and raise its quality:
    python_quick_fix
  • Quick documentation:
    python_quick_doc
    and various external documentation resources.
  • Python console: you can start it from Tools | Python Console or Find Action dialog, alternatively you can execute any Python code in console by simply pressing Alt+Shift+E.
  • Run and debug for Python configurations.
  • Unit testing.

Short demo below will demonstrate you some of the features:
https://www.youtube.com/watch?v=Cmd6M8l2nSs

Download the build and give it a try. Share your feedback in the comments section below. We’ll be glad to hear what you think about the Python support in CLion.

And in case you are interested in more PyCharm features, find a set of video tutorials covering PyCharm functionality and features here.

Sincerely yours,
The CLion Team

image description