Score:0

Create .desktop launcher to start a terminal with a python virtual environment enable

im flag

Despite the similar questions/answers I can find on this forum and on others, I am not able to create a desktop launcher that start a terminal with a python environment activated.

To activate the environment in an open terminal, the command is source /pyvenv/mne/bin/activate.

My best guess, not working, is:

[Desktop Entry]
Version=1.0
Name=Terminal-MNE
Exec=gnome-terminal --window -e "bash -c 'source /pyvenv/mne/bin/activate'"
Icon=org.gnome.Terminal
Terminal=true
Type=Application
Categories=Application

Any better idea?

Mathieu avatar
im flag
If the downvote could be accompanied by an explanation, I would gladly improve the question if it means a solution to the issue I haven't been able to solve in hours.
Albin avatar
br flag
I didn't downvote, but I think it's a bad solution. If you always want to run something for the interactive shell, this is how you do it https://unix.stackexchange.com/a/129144
Mathieu avatar
im flag
Editing the `.bashrc` is not a solution in my case. Most of the time, I do want the default shell, but I would also like to create a shortcut to a shell with this environment activated. The reason is that most of my users don't know about 'source' and editing bashrc or bash profile, thus a shortcut to enable this shell with this env would be useful.
Albin avatar
br flag
In that case I think your proposal is good, but you should probably have clarified the use case more in the question. I was wondering why you didn't just activate it universally or just run the command when you need it. By if you're a system admin and want to handle this for non-technical users a secondary desktop entry for "terminal with pyenv" makes sense. I upvoted the question. It's not a bad question. People here can be way too harsh.
Mathieu avatar
im flag
@Albin Thank you, agree I should have clarified the use case. Despite the month old, I still haven't figured out how to get it working, although it fell to the bottom of my priority list :/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.