Recreating PyCharm launcher in Ubuntu

53,509

Solution 1

First start pyCharm from it's bin folder via command line

$ ./pycharm.sh

Then, goto

Tools -> Create Desktop Entry.

It will create a correct Desktop file in the correct place. Afterward you can initiate it from the menu and pin the icon or drag and drop it to the bar. This way, you don't have to deal with .desktop files and mumbo jumbo..

Solution 2

I managed to solve it. The thing is, Pycharm already installs a launcher inside .local/share/applications. Thus, you need to get rid of it before proceeding to create your own. After that, all you have to do is add your own *.desktop file to the applications directory inside usr/share/applications/.

You need to create your .desktop file using sudo and inside the desktop file:

[Desktop Entry]
Encoding=UTF-8
Name=PyCharm
Exec=/opt/pycharm-3.0.1/bin/pycharm.sh
Icon=/opt/pycharm-3.0.1/bin/pyCharm.png  # Changed from pycharm_32.png
Type=Application
Categories=Development;
StartupWMClass=PyCharm

After that is done, you can launch your app properly. Please note that pycharm.sh must also have execution rights.

Solution 3

With Ubuntu 16.04, I used the "snap" installer, which doesn't include an easily accessible icon (there's probably one hidden inside the snap image, but it's hard to get at). Instead it shows a grey question mark icon in the launcher instead. Also there doesn't seem to be a Tools > Create Desktop Entry option in version 2017.3.3 as far as I can see - maybe it has been moved somewhere.

So I copied pycharm.png from an earlier non-snap Community installation, saved it somewhere, then created ~/.local/share/applications/jetbrains-pycharm-ce.desktop:

[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm Community Edition
Icon=/path/to/pycharm.png
Exec="/snap/bin/pycharm-community" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce

Then when I start PyCharm (from the command line), the launcher item appears with the correct icon, and then I right-click on it and choose "Lock to Launcher", and it now persists.

A downside is that the icon will not be automatically updated with the app, so it might fall out of date.

Solution 4

When Tools -> Create Desktop Entry does not work:

Create a new file on your desktop (using vi or a similar command) named:
jetbrains-pycharm.desktop

Paste the following inside:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm
Icon=/opt/pycharm-5.0.1/bin/pycharm.png
Exec="/opt/pycharm-5.0.1/bin/pycharm.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm

Keep in mind to change the path and version number of icon and exec properties above.

Tested on various versions of PyCharm - like a charm ☺

Solution 5

In case you just want to update your launcher to point to an updated PyCharm, for me changing 4.0.4 to 4.0.6 in the following worked:

nano /usr/share/applications/jetbrains-pycharm.desktop
Share:
53,509

Related videos on Youtube

Games Brainiac
Author by

Games Brainiac

The real challenges that we face are social. Should you ever feel grateful because of one of my answers, you need do nothing more than say thanks. I don't do what I do so that I can get more wish-list items, or get you to hire me for mentoring. I do it because I like helping people when I have the time.

Updated on July 05, 2022

Comments

  • Games Brainiac
    Games Brainiac almost 2 years

    I installed pycharm normally via bin/pycharm.sh, but the mistake I made was doing bash pycharm.sh while the pycharm directory has inside the Downloads folder.

    I later on moved the directory to /opt/Pycharm/. This is causing the once functioning unity launcher (which was added when PyCharm was initially installed) to fail every time I attempt to use it (as expected).

    How can I re-add pycharm.sh as a lauchable app from the unity launcher? I know the location of the pycharm.sh file. I've tried to add it to /usr/bin/ but that does not change anything.

    I can still launch pycharm via bash /usr/opt/Pycharm/bin/Pycharm.sh. But this is tedious.

    UPDATE

    I have tried making a new .desktop file for pycharm, using the following script:

    [Desktop Entry]
    Encoding=UTF-8
    Name=PyCharm
    Exec=/opt/Pycharm-3.0.1/bin/pycharm.sh
    Icon=/opt/Pycharm-3.0.1/bin/PyCharm_32.png
    Type=Application
    Categories=Development;
    StartupWMClass=PyCharm
    

    However, I get a "Unable to save Pycharm.desktop" error when I try to save the file inside /usr/share/applications/pycharm.desktop. Any help regarding this would be deeply appreciated.

    • Phlip
      Phlip over 10 years
      A workaround - get into your Downloads folder, and run ln -s /opt/Pycharm-3.0.1. Now the charm script is happy. But see below.
  • Games Brainiac
    Games Brainiac over 10 years
    I'm afraid this does not open up anything :( How can I create a .desktop file from scratch?
  • Phlip
    Phlip over 10 years
    no idea why you insist on clicking something when you should have a bash open, but see my symlink trick.
  • Games Brainiac
    Games Brainiac over 10 years
    Well, there is a bash inside pycharm, so there's no point in keeping an extra terminal open.
  • t2d
    t2d over 9 years
    After the update from pycharm 3 to 4, I had to delete .local/share/applications/jetbrains-pycharm.desktop. Then I could create a new one.
  • Tim Tisdall
    Tim Tisdall over 8 years
    If you run it with sudo then the configuration settings end up in /root/... I don't think that's what you want to do. If you run it as the regular user with sudo rights then it prompts for a password when you run "Create Desktop Entry"
  • user
    user almost 8 years
    No launcher is created in Ubuntu 16.04, PyCharm 2016.1.
  • mohaghighat
    mohaghighat over 6 years
    There is no "Tools -> Create Desktop Entry" in PyCharm 2017.3.3 (Community Edition).
  • robbie70
    robbie70 about 6 years
    worked for me - using Ubuntu 16.04 and Pycharm 2018.1.1 - thank you !