Reputation: 377
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.
I set up another environment in addition to the default using the following command:
conda create --name py3datascience numpy pandas scikit-learn matplotlib beautifulsoup4 cairo hdf5 jupyter nltk patsy pytables pystan pymc requests sas7bdat seaborn sqlite statsmodels spyder
As expected, I now have an additional environment called py3datascience. I can launch Spyder (connected to this environment) from the terminal using the following:
source activate py3datascience
spyder
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.
I created a shell script with following commands:
source activate py3datascience
spyder
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:
[Desktop Entry]
Version=1.0
Type=Application
Name=SpyderPy3
Comment=
Exec=/home/user1/scripts/SpyderPy3.sh
Icon=
Path=
Terminal=false
StartupNotify=true
I found a .desktop file in the appropriate environment folder that was created by the conda commands, it is here:
/home/user1/anaconda/envs/py3datascience/share/applications/spyder3.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=SpyderPy3
Comment=
Exec=/home/user1/scripts/SpyderPy3.sh
Icon=
Path=
Terminal=false
StartupNotify=true
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:
source activate py3datascience
spyder
Upvotes: 4
Views: 9438
Reputation: 43
Paths have changed meanwhile, and the Exec
line in co_biostat's answer (https://stackoverflow.com/a/39799876/7235455) can be simplified. For anyone looking for an updated version like me today, here's my .desktop file:
[Desktop Entry]
Version=1.0
Type=Application
Name=Spyder 5
GenericName=Spyder 5
Comment=The Scientific Python Development Environment
TryExec=/home/xxx/anaconda3/bin/spyder
Exec=/home/xxx/anaconda3/bin/spyder %F
Categories=Development;Science;IDE;Qt;
Icon=/home/xxx/anaconda3/share/icons/spyder.png
Terminal=false
StartupNotify=true
MimeType=text/x-python;
Assuming you installed Anaconda in the default location, just replace 'xxx' in the TryExec
, Exec
and Icon
line with your username. If you installed in a custom location, please change the paths accordingly.
Upvotes: 1
Reputation: 377
After a bit of research, I figured out my issue.
I needed to create a *.desktop file with the following contents:
[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
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:
source activate py3ds
spyder
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.
Upvotes: 2