3 Methods to install PyCharm Community Edition on Linux

PyCharm is a professional Python IDE (Integrated Development Environment) developed by JetBrains, which supports a lot of features like code completion, refactoring, debugging, etc. Two versions of the IDE exist: the “Professional” version, which must be purchased, and the free, “Community” version, which is based on open source software, and can be downloaded and installed free of charge. Various methods can be used to install the IDE on Linux.

In this tutorial we see how to install PyCharm Community Edition on Linux as a snap package, as a flatpak or by downloading the portable tarball from the official JetBrain site.

In this tutorial you will learn:

  • How to install PyCharm Community Edition as a snap package
  • How to install PyCharm Community Edition as a flatpak
  • How to install PyCharm Community Edition from the portable tarball
article-main
How to install PyCharm Community Edition on Linux

 Software requirements and conventions used

CategoryRequirements, Conventions or Software Version Used
SystemDistribution-independent
SoftwareSnap|Flatpak|tar (Depends on the installation method)
OtherNone
Conventions# – requires given linux-commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux-commands to be executed as a regular non-privileged user

Introduction

In this tutorial we see how to install the community version of PyCharm as a snap package, as a flatpak, or by extracting the tarball provided on the official JetBrain site. When using the first two methods, I will assume you are familiar with flatpack or snap packages; if you are not, you can take a look at our tutorials on how to use those installation methods before keep following this guide.

Installing PyCharm CE as a snap package

Snap packages and the Snappy package manager were originally developed by Canonical and meant to be used on Ubuntu exclusively, but later they became available on other distributions (Fedora, for example) as an alternative to Flatpaks. As Flatpacks, they provide a way to distribute applications together with their dependencies, (potentially in a sandboxed environment, in order to isolate them from the rest of the system).



PyCharm Community Edition is officially distributed by JetBrains as a snap package, so to install it, all we have to do, once we installed snap, is to run the following command:

$ sudo snap install pycharm-community --classic

Why we need to include the --classic option in the command above? Unfortunately the “pycharm-community” package is published by using the so called “classic” confinement: this means that the package actually uses no sandbox and may perform changes to the rest of the system. We are warned about this and the possible security risks involved, when we try to perform the installation omitting the aforementioned option:

error: This revision of snap "pycharm-community" was published using classic
       confinement and thus may perform arbitrary system changes outside of the
       security sandbox that snaps are usually confined to, which may put your
       system at risk.

       If you understand and want to proceed repeat the command including
       --classic.

What the --classic option does is to disable confinement, so it is mandatory for the installation to succeed. In order to perform an installation using classic confinement, the /snap directory must exist on our system. If it doesn’t, we can create it as a symbolic link which points to the /var/lib/snapd/snap directory:

$ sudo ln -s /var/lib/snapd/snap /snap

Once the directory exists, the installation should be performed without problems. If you can’t find the PyCharm desktop launcher in the application menu, just try to logout and log back in.

Installing PyCharm Community Edition as a flatpak

PyCharm is also available as a flatpak, in the flathub.org repository. Flatpaks, as you probably know, can be installed system-wide or just for a specific user. To perform an installation of the second type, we just need to add the --user option to the installation command; if we do, we can avoid using privilege escalation. This is the approach we will use in this tutorial.



The first thing we should do is to make sure the flathub repository is available as a software source. We can do it by running the following command:

$ flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Once we are sure the repository is available, to install PyCharm CE, we can run:

$ flatpak --user install flathub com.jetbrains.PyCharm-Community

To run, the application requires the com.jetbrains.PyCharm-Community runtime. We will be prompted to confirm that we want to install it. Just answer Y and press enter to confirm:

Required runtime for com.jetbrains.PyCharm-Community/x86_64/stable (runtime/org.freedesktop.Sdk/x86_64/21.08) found in remote flathub
Do you want to install it? [Y/n]: y

A summary of the flatpak dependencies and the permissions that will be granted to them will be displayed. Just confirm the installation again:

com.jetbrains.PyCharm-Community permissions:
    ipc       network      pulseaudio      session-bus      x11      devices      file access [1]      dbus access [2]

    [1] host, xdg-run/keyring
    [2] org.freedesktop.Notifications, org.freedesktop.secrets


        ID                                              Branch            Op           Remote            Download
 1.     org.freedesktop.Platform.GL.default             21.08             i            flathub           < 131.3 MB
 2.     org.freedesktop.Platform.VAAPI.Intel            21.08             i            flathub            < 11.8 MB
 3.     org.freedesktop.Platform.openh264               2.0               i            flathub             < 1.5 MB
 4.     org.freedesktop.Sdk.Locale                      21.08             i            flathub           < 330.8 MB (partial)
 5.     org.freedesktop.Sdk                             21.08             i            flathub           < 474.8 MB
 6.     com.jetbrains.PyCharm-Community                 stable            i            flathub           < 564.2 MB

Proceed with these changes to the user installation? [Y/n]: y

Now wait until the installation is complete. At the end you should find the PyCharm launcher in your application menu. If you don’t, just restart your session.

Install PyCharm from tar archive

The last method we can use to install PyCharm Community Edition is to download the tarball from the official site. The version available at the time of writing is 2021.1.1. We can download the tarball by navigating opening the link with our favorite web browser, or we straight from the command line with curl:

$ curl -L https://download.jetbrains.com/python/pycharm-community-2022.1.1.tar.gz  | tar -xvz

The command above will download the tarball called pycharm-community-2022.1.1.tar.gz and extract it on the fly in the directory from which it is invoked. In the command we used the -L option (short for --location) to handle redirections.



Once the process is finished, we will find a directory called pycharm-community-2022.1.1. To start PyCharm we must execute the pycharm.sh script which is found under the bin subdirectory. For the sake of this example I extracted the directory under my HOME, so I would run:

$ ~/pycharm-community-2022.1.1/bin/pycharm.sh

To avoid having to invoke the script by providing its full path each time, we can create a symbolic link which points to it inside the ~/.local/bin directory (or any other directory which is part of your PATH), for example:

$ ln -s ~/pycharm-community-2022.1.1/bin/pycharm.sh ~/.local/bin

We could also create a desktop launcher, to be able to launch PyCharm from our application menu. The launcher should be created as ~/.local/share/applications/pycharm.desktop (the name of the launcher is arbitrary). We open the file with our favorite text editor and paste the following content inside it:

[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm Community Edition
Icon=/home/egdoc/pycharm-community-2022.1.1/bin/pycharm.png
Exec=pycharm.sh
Comment=Python IDE for Professional Developers
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce
StartupNotify=true

In the snippet above, you can see I provided the full path to the icon I want to use for the launcher as value of Icon. The icon is already included in the directory which was created when we extracted the tarball; adapt the value so that it matches the location you used. The launcher should appear in you application menu under the “Development” category.

Conclusions

In this article we learned how to install PyCharm Community Edition on Linux. We saw how to install it as a snap package, as a flatpak, and finally by simply downloading the tarball from the JetBrains site. When using the latter method, we also saw how to create a desktop launcher, to be able to launch the application from the applications menu.



Comments and Discussions
Linux Forum