25

I have used the guide from similar question (How can I create launchers on my desktop?)

but nothing works when it comes to Ananconda3 shortcut.

Here is my desktop file for anaconda:

[Desktop Entry]
Version=1.0
Type=Application
Name=Anaconda-Navigator
GenericName=Anaconda
Exec=bash -c anaconda-navigator
Icon=/home/paygilant/anaconda3/lib/python3.6/site-packages/anaconda_navigator/s$
Terminal=false
StartupNotify=true
MimeType=text/x-python;

I have succeeded the image part, but can't actually launch it. There is an icon on my desktop and I have put in the command bash -c anaconda-navigator.

Please help me identify what am I missing?

steves
  • 371
  • 1
    "can't actually launch it" is not very helpful. What goes wrong if you try to launch the application by double-clicking the .desktop launcher? – pomsky Mar 19 '18 at 13:45
  • 1
    Also can you launch it by running bash -c anaconda-navigator in Terminal? – pomsky Mar 25 '18 at 18:31
  • @pomsky I tried it (my first time) and it works. However it needs the full path for the desktop launcher. See my answer below. – user10853 Mar 26 '18 at 21:23
  • It's unfortunate that this used to be as easy as a right-click and no longer is. Even the explanation below of needing to write a .desktop file is not tops as it leaves plenty of room to mess things up, like the path to the icon being not visually verifiable, or wrong quotes in the bash call, etc. – Mittenchops May 15 '18 at 19:42

7 Answers7

18

Following steps work in Ubuntu 16.04, but I don't know if it works in 17.04.

  1. Create a shell script /home/paygilant/bin/anaconda.sh

    export CONDA_PYTHON_EXE=/home/paygilant/anaconda3/bin/python
    export PATH=/home/paygilant/anaconda3/bin:$PATH
    python /home/paygilant/anaconda3/bin/anaconda-navigator
    
  2. Create a desktop file /home/paygilant/anaconda.desktop

    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Anaconda-Navigator
    GenericName=Anaconda
    Exec=/bin/bash "/home/paygilant/bin/anaconda.sh"
    Icon=/home/paygilant/anaconda3/lib/python3.6/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
    Terminal=false
    StartupNotify=true
    
  3. Run sudo desktop-file-install anaconda.desktop. After 10~20 seconds, you can see Anaconda shortcut in dash.

  • When I type anaconda-navigator --version in the terminal i get 1.9.6, yet when adding this entry to the desktop entry and installing I get anaconda-navigator.desktop: error: value "1.9.6" for key "Version" in group "Desktop Entry" is not a known version – alonso s Feb 17 '19 at 23:10
  • 1
    As the document https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles said, Version is the version of this .desktop file. It should be x.y format and is irrelevant to Anaconda version. – Ping Chu Hung Feb 18 '19 at 05:04
8

First check if anaconda3 is installed on your system or not (Sometime the package may be broken due to network issues during installation). And whether you are able to launch anaconda-navigator without a desktop entry or not (See how to launch anaconda-navigator without a desktop-entry, later in this post).

For creating a desktop entry

Step 1. Open your text editor and save the following content as Anaconda.desktop to your home directory.

[Desktop Entry]
Version=1.0
Type=Application
Name=Anaconda-Navigator
GenericName=Anaconda
Comment=Scientific Python Development Environment - Python3
Exec=bash -c 'export PATH="/home/jishan/anaconda3/bin:$PATH" && /home/jishan/anaconda3/bin/anaconda-navigator'
Categories=Development;Science;IDE;Qt;Education;
Icon=/home/jishan/anaconda3/lib/python3.6/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
Terminal=false
StartupNotify=true
MimeType=text/x-python;

Change the user-name to your username in Icon=/home/jishan/anaconda3/lib/python3.6/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png i.e. replace jishan by your username.

Step 2. Copy your Anaconda.desktop to /usr/share/applications/ as root (Because you might need permission to copy at /usr/share/applications/)

sudo cp Anaconda.desktop /usr/share/applications

This will create a desktop entry named Anaconda in /usr/share/applications/.

Step 3. Check if Anaconda is added to your application dock. If you didn't find it, search it in search-bar. Or you can run directly from /usr/share/applications/Anaconda.desktop.

Launch Anaconda-navigator without a desktop entry

Your user (not root) may not have access to anaconda-navigator or it is not activated it yet.

Source ~/anaconda3/bin/activate root

This will result in single line showing (bash), if installed. If it is not installed, install it from here.

If installed, you can launch now by

anaconda-navigator

This will result in opening anaconda-navigator. (For each time you've to activate root as soon as your session is destroyed).

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
3

Tried and tested. You need to give it the full path for some reason:

[Desktop Entry]
Name=Anaconda
Exec=bash -c 'export PATH="/home/paygilant/anaconda3/bin:$PATH" && /home/paygilant/anaconda3/bin/anaconda-navigator'
Terminal=false
Type=Application
StartupNotify=true

Then to add it to the Unity/Gnome dash:

cp -t ~/.local/share/applications ~/Desktop/anaconda_launcher.desktop

Note: I did not add an icon here and I am not sure the path you use for it is a good one (didn't check).

David Foerster
  • 36,264
  • 56
  • 94
  • 147
user10853
  • 1,566
1

The answer has two steps:

  1. Create Anaconda.desktop

    Open your text editor and save the following content as Anaconda.desktop to your home directory.

    Anaconda.desktop contents:

    [Desktop Entry]
    Type=Application
    Name=Anaconda
    Exec=anaconda-navigator
    Terminal=false
    Icon=/home/ganeshan/anaconda3/lib/python3.7/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
    

    Use your icon path instead of the one here.

  2. Move your .desktop file to the application folder /usr/share/applications/, now search for Anaconda in dock and click.

This method works for me (Ubuntu 18.10)

Olorin
  • 3,488
0

Do you have the ownership over the file? A common mistake I see in this case is people using chmod +X as root or sudo.

Can you give the output of the following comment?

ls -l /path/to/file

Second question is are you using Unity or Gnome3? Normally you should be using gnome3 instead of Unity in 17.10 you may want to look up a guide for gnome3 instead of older versions. This should work How can I create launchers on my desktop?

pa4080
  • 29,831
0

To run anaconda with launcher icon you need first to add the path to the root environment PATH

sudo echo "PATH=$PATH:/home/user/anaconda3/bin" >> /etc/environment

restart your PC,

then surprise surprise the icon you created would work

0

This is working in Ubuntu 18

Go to /usr/share/applications/

Create a file using sudo Anaconda.desktop

e.g:

sudo vi Anaconda.desktop

Paste the following:

[Desktop Entry]
 Version=1.0
 Type=Application
 Name=Anaconda-Navigator
 GenericName=Anaconda
 Comment=Scientific Python Development Environment - Python3
 Exec=bash -c 'export PATH="/home/superman/anaconda3/bin:$PATH" && /home/superman/anaconda3/bin/anaconda-navigator'
 Categories=Development;Science;IDE;Qt;Education;
 Icon=/home/superman/anaconda3/lib/python3.6/site-packages/anaconda_navigator/static/images/anaconda-icon-256x256.png
 Terminal=false
 StartupNotify=true
 MimeType=text/x-python;

Change superman to the your user folder.

user3785966
  • 101
  • 1