1

I just tried to create a small shortcut to activate a conda env and run jupyter notebook. But I can't run it by double clicking.

I added chmod +x and changed the behaviour in nautilus (as recommended here). Nothing happens. The script only contains

source activate tensorflow
jupyter notebook

Later I added #! /bin/bash but that didn't help either.

When I run the script from terminal with source myscript.sh it works fine.

Edit

This is not a duplicate. I've read that thread and did what was recommend ( as I've pointed out above) but this doesn't work for me.

Picard
  • 311
  • For the difference between executing a script and sourcing it, see http://askubuntu.com/q/286621/85695. Note that if you run your script with sh, you can't use source (that is a bash command), use . instead: . activate tensorflow. Also note that you might need to use the full path to the activate executable. Actually, if you do what is explained in the duplicate and the script still fails, you should ask a new question. I'd be surprised if that command works the way you expect it to. – terdon Mar 14 '17 at 09:22
  • If you have done what is recommended, please [edit] your question and clarify. You don't mention any changes in nautilus settings in your question. – terdon Mar 14 '17 at 09:27
  • Your script may depend on some environment variables, etc. set in your .bashrc or something. – muru Mar 14 '17 at 09:29
  • @terdon: "... and changed the behaviour in nautilus." Also the link for the difference between executing and sourcing points to the 'duplicate'. I found the solution, but apparently I am not able to post the solution as an answer. – Picard Mar 14 '17 at 09:35
  • The problem is due to the missing env variables. That's why it works from terminal. If I supply the full path for everything it works as expected. – Picard Mar 14 '17 at 09:39
  • OK, if you found the answer, please do post it. And sorry about the wrong link, copy/paste error. This is the one I meant: http://askubuntu.com/q/601055/85695 – terdon Mar 14 '17 at 09:43

1 Answers1

1

Ok I figured it out:

The problem is due to the missing paths for anaconda (namely jupyter and activate). If I run my script via terminal it has all the necessary paths from .bashrc. When I try to run the script from nautilus it doesn't have the necessary paths.

The solution is simply to provide the full path for every executables within that script.

However I'm not sure how to shut down the jupyter notebook this way afterwards.

Picard
  • 311