3

I have installed Spyder Python IDE in a virtual environment. For this purpose I used the following command:

python3 -m venv spyder-env
source spyder-env/bin/activate

I have to switch to the virtual environment and then type spyder. I am using Ubuntu 20.04. Can I create a bash command as a shortcut and then create a desktop icon to directly open it in order to save time?

1
  • 2
    If you are already using a bash shell by default, try source /home/<your_username>/spyder-env/bin/activate; spyder. If you are using the Ubuntu default dash (not bash) shell, there's one extra step to use bash: try /bin/bash -c "source /home/<your_username>/spyder-env/bin/activate; spyder". Bash is required to use 'source', which dash lacks.
    – user535733
    Oct 25, 2021 at 0:05

1 Answer 1

2

I reach to this question with a similar problem, but in my case my virtual environment was created on conda... I am sharing the solution for the desktop icon I found for conda environment (I named the environment 'spyder'), for someone else struggling with a similar problem...:

Name=Spyder5
Comment=spyder inside virtual environment
Exec=bash -i -c "conda activate spyder; python -m spyder.app.start"
Icon=/home/<username>/anaconda3/envs/spyder/share/icons/spyder.png
Type=Application
Terminal=true

Inside spyder.desktop file created as described here. The bash -i -c, and the ; mentioned by the user5357633 in the comment above directed me to the solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .