How to set up different desktop launchers for anaconda spyder using conda environments?
<p>I have created a virtual machine for use in an upcoming data science lecture. I installed CentOS minimal into Virtualbox and included an XFCE desktop. I have also installed two analytic stack python versions (2.7, 3.5) using Anaconda mini and the conda environment manager. </p>

<p>I set up another environment in addition to the default using the following command:</p>

<pre><code>conda create --name py3datascience numpy pandas scikit-learn matplotlib beautifulsoup4 cairo hdf5 jupyter nltk patsy pytables pystan pymc requests sas7bdat seaborn sqlite statsmodels spyder
</code></pre>

<p>As expected, I now have an additional environment called py3datascience. I can launch Spyder (connected to this environment) from the terminal using the following:</p>

<pre><code>source activate py3datascience
spyder
</code></pre>

<p>And everything works as expected. I would like to create a desktop shortcut to launch Spyder in this specific environment (and another desktop shortcut for the Python 2.7 I will install), but I have not been able to do it. </p>

<p>I created a shell script with following commands:</p>

<pre><code>source activate py3datascience
spyder
</code></pre>

<p>and placed it in /home/user/scripts. When I run this script from the terminal, it works as expected (Spyder Launches in the correct environment). I tried creating a *.desktop file that would run this script and it does not work. It fails to launch Spyder, but it also fails to give me an error message. Here is the contents of my failed desktop file:</p>

<pre><code>[Desktop Entry]
Version=1.0
Type=Application
Name=SpyderPy3
Comment=
Exec=/home/user1/scripts/SpyderPy3.sh
Icon=
Path=
Terminal=false
StartupNotify=true
</code></pre>

<p>I found a .desktop file in the appropriate environment folder that was created by the conda commands, it is here: </p>

<p>/home/user1/anaconda/envs/py3datascience/share/applications/spyder3.desktop</p>

<pre><code>[Desktop Entry]
Version=1.0
Type=Application
Name=SpyderPy3
Comment=
Exec=/home/user1/scripts/SpyderPy3.sh
Icon=
Path=
Terminal=false
StartupNotify=true
</code></pre>

<p>My lack of linux skills are likely showing, so I am seeking help on how to proceed. The basic question is, after using conda to set up different environments, how can I create desktop or panel shortcuts (in linux, specifically CentOS with XFCE) to the appropriate Spyder installation? The following commands in terminal accomplish this, but I need a panel or desktop shortcut:</p>

<pre><code>source activate py3datascience
spyder
</code></pre>

<p>After a bit of research, I figured out my issue. </p>

<p>I needed to create a *.desktop file with the following contents:</p>

<pre><code>[Desktop Entry]
Version=1.0
Type=Application
Name=Spyder py3
Comment=
Exec=xfce4-terminal -e "bash -c 'cd /home/user1/anaconda/bin;source activate py3ds;spyder'"
Icon=
Path=
Terminal=true
StartupNotify=false
</code></pre>

<p>A bit of explanation...if I open a terminal shell and type in the following commands, the environment is activated and then Spyder is launched: </p>

<pre><code>source activate py3ds
spyder
</code></pre>

<p>I did not need to be in any specific directory for this to work. However, when creating the .desktop file and entering the shell commands, I needed to first cd to the appropriate directory and then run source activate. Perhaps I also could have specified the full path in the source activate command instead. </p>

python linux anaconda spyder conda