Launching script containing virtual env through desktop icon

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I want to launch Spyder with tensorflow environment activated directly through a desktop icon. For this purpose, I created a desktop icon launching a virtualenv and then my application. Many posts already exist but I cannot find a solution for this exact problem. Here is my spyder.sh file:



#!/bin/bash
source /home/alexis/tensorflow/bin/activate
spyder3


and here is my desktop entry:



[Desktop Entry]
Version=1.0
Name=Spyder
Comment=Spyder
Exec='/home/alexis/Launcher/spyder.sh'
Icon=spyder3
Terminal=true
Type=Application
Categories=Application;
Name[en_US]=Spyder


The files have chmod +x. From a terminal, the script works as expected. From the desktop, the script launches Spyder but the environment is not activated. What I am missing?



Related questions not answering my question:
How do I make a desktop icon to launch a program?
and
How do I automate the activation of Python environment










share|improve this question



























    up vote
    0
    down vote

    favorite












    I want to launch Spyder with tensorflow environment activated directly through a desktop icon. For this purpose, I created a desktop icon launching a virtualenv and then my application. Many posts already exist but I cannot find a solution for this exact problem. Here is my spyder.sh file:



    #!/bin/bash
    source /home/alexis/tensorflow/bin/activate
    spyder3


    and here is my desktop entry:



    [Desktop Entry]
    Version=1.0
    Name=Spyder
    Comment=Spyder
    Exec='/home/alexis/Launcher/spyder.sh'
    Icon=spyder3
    Terminal=true
    Type=Application
    Categories=Application;
    Name[en_US]=Spyder


    The files have chmod +x. From a terminal, the script works as expected. From the desktop, the script launches Spyder but the environment is not activated. What I am missing?



    Related questions not answering my question:
    How do I make a desktop icon to launch a program?
    and
    How do I automate the activation of Python environment










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to launch Spyder with tensorflow environment activated directly through a desktop icon. For this purpose, I created a desktop icon launching a virtualenv and then my application. Many posts already exist but I cannot find a solution for this exact problem. Here is my spyder.sh file:



      #!/bin/bash
      source /home/alexis/tensorflow/bin/activate
      spyder3


      and here is my desktop entry:



      [Desktop Entry]
      Version=1.0
      Name=Spyder
      Comment=Spyder
      Exec='/home/alexis/Launcher/spyder.sh'
      Icon=spyder3
      Terminal=true
      Type=Application
      Categories=Application;
      Name[en_US]=Spyder


      The files have chmod +x. From a terminal, the script works as expected. From the desktop, the script launches Spyder but the environment is not activated. What I am missing?



      Related questions not answering my question:
      How do I make a desktop icon to launch a program?
      and
      How do I automate the activation of Python environment










      share|improve this question















      I want to launch Spyder with tensorflow environment activated directly through a desktop icon. For this purpose, I created a desktop icon launching a virtualenv and then my application. Many posts already exist but I cannot find a solution for this exact problem. Here is my spyder.sh file:



      #!/bin/bash
      source /home/alexis/tensorflow/bin/activate
      spyder3


      and here is my desktop entry:



      [Desktop Entry]
      Version=1.0
      Name=Spyder
      Comment=Spyder
      Exec='/home/alexis/Launcher/spyder.sh'
      Icon=spyder3
      Terminal=true
      Type=Application
      Categories=Application;
      Name[en_US]=Spyder


      The files have chmod +x. From a terminal, the script works as expected. From the desktop, the script launches Spyder but the environment is not activated. What I am missing?



      Related questions not answering my question:
      How do I make a desktop icon to launch a program?
      and
      How do I automate the activation of Python environment







      .desktop virtualenv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 13:38

























      asked Mar 22 at 13:32









      ahstat

      1014




      1014




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          To run your python script within the virtual environment, you simply have to execute the python binary which is in the bin folder of your virtual env folder.



          Ie : if your virtual env within /home/alexis/myvirtualenv and if the script you want to execute is named /home/alexis/scripts/my_python_file.py, you will have to run your python script this way :



          /home/alexis/myvirtualenv/bin/python /home/alexis/scripts/my_python_file.py


          For your specific needs :
          Try to put the following code within spyder.sh :



          #!/bin/bash
          /home/alexis/tensorflow/bin/python spyder3 # you may have to put the full path to spyder3





          share|improve this answer






















          • The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
            – ahstat
            Mar 24 at 2:28










          • When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
            – ahstat
            Mar 24 at 2:30










          • I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
            – ahstat
            Mar 24 at 11:10










          • i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
            – rebrec
            Mar 24 at 16:24










          • same error "There was an error launching the application."
            – ahstat
            Mar 25 at 8:25










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1018253%2flaunching-script-containing-virtual-env-through-desktop-icon%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          To run your python script within the virtual environment, you simply have to execute the python binary which is in the bin folder of your virtual env folder.



          Ie : if your virtual env within /home/alexis/myvirtualenv and if the script you want to execute is named /home/alexis/scripts/my_python_file.py, you will have to run your python script this way :



          /home/alexis/myvirtualenv/bin/python /home/alexis/scripts/my_python_file.py


          For your specific needs :
          Try to put the following code within spyder.sh :



          #!/bin/bash
          /home/alexis/tensorflow/bin/python spyder3 # you may have to put the full path to spyder3





          share|improve this answer






















          • The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
            – ahstat
            Mar 24 at 2:28










          • When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
            – ahstat
            Mar 24 at 2:30










          • I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
            – ahstat
            Mar 24 at 11:10










          • i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
            – rebrec
            Mar 24 at 16:24










          • same error "There was an error launching the application."
            – ahstat
            Mar 25 at 8:25














          up vote
          0
          down vote













          To run your python script within the virtual environment, you simply have to execute the python binary which is in the bin folder of your virtual env folder.



          Ie : if your virtual env within /home/alexis/myvirtualenv and if the script you want to execute is named /home/alexis/scripts/my_python_file.py, you will have to run your python script this way :



          /home/alexis/myvirtualenv/bin/python /home/alexis/scripts/my_python_file.py


          For your specific needs :
          Try to put the following code within spyder.sh :



          #!/bin/bash
          /home/alexis/tensorflow/bin/python spyder3 # you may have to put the full path to spyder3





          share|improve this answer






















          • The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
            – ahstat
            Mar 24 at 2:28










          • When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
            – ahstat
            Mar 24 at 2:30










          • I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
            – ahstat
            Mar 24 at 11:10










          • i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
            – rebrec
            Mar 24 at 16:24










          • same error "There was an error launching the application."
            – ahstat
            Mar 25 at 8:25












          up vote
          0
          down vote










          up vote
          0
          down vote









          To run your python script within the virtual environment, you simply have to execute the python binary which is in the bin folder of your virtual env folder.



          Ie : if your virtual env within /home/alexis/myvirtualenv and if the script you want to execute is named /home/alexis/scripts/my_python_file.py, you will have to run your python script this way :



          /home/alexis/myvirtualenv/bin/python /home/alexis/scripts/my_python_file.py


          For your specific needs :
          Try to put the following code within spyder.sh :



          #!/bin/bash
          /home/alexis/tensorflow/bin/python spyder3 # you may have to put the full path to spyder3





          share|improve this answer














          To run your python script within the virtual environment, you simply have to execute the python binary which is in the bin folder of your virtual env folder.



          Ie : if your virtual env within /home/alexis/myvirtualenv and if the script you want to execute is named /home/alexis/scripts/my_python_file.py, you will have to run your python script this way :



          /home/alexis/myvirtualenv/bin/python /home/alexis/scripts/my_python_file.py


          For your specific needs :
          Try to put the following code within spyder.sh :



          #!/bin/bash
          /home/alexis/tensorflow/bin/python spyder3 # you may have to put the full path to spyder3






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 22 at 13:58

























          answered Mar 22 at 13:52









          rebrec

          1816




          1816











          • The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
            – ahstat
            Mar 24 at 2:28










          • When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
            – ahstat
            Mar 24 at 2:30










          • I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
            – ahstat
            Mar 24 at 11:10










          • i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
            – rebrec
            Mar 24 at 16:24










          • same error "There was an error launching the application."
            – ahstat
            Mar 25 at 8:25
















          • The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
            – ahstat
            Mar 24 at 2:28










          • When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
            – ahstat
            Mar 24 at 2:30










          • I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
            – ahstat
            Mar 24 at 11:10










          • i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
            – rebrec
            Mar 24 at 16:24










          • same error "There was an error launching the application."
            – ahstat
            Mar 25 at 8:25















          The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
          – ahstat
          Mar 24 at 2:28




          The code is working in a terminal (launching Spyder and access to tensorflow), but not through the desktop icon (launching Spyder but not in my virtualenv). I've replaced spyder3 with /usr/bin/spyder3
          – ahstat
          Mar 24 at 2:28












          When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
          – ahstat
          Mar 24 at 2:30




          When the second line is only "/home/alexis/tensorflow/bin/python3", the problem is similar: OK in a terminal (open python3 in virtualenv), but not through desktop icon (open python3 but not in my virtualenv)
          – ahstat
          Mar 24 at 2:30












          I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
          – ahstat
          Mar 24 at 11:10




          I have "There was an error launching the application." I tried with ", ' and with nothing. If I let Exec="xterm", it works but it is only an xterm
          – ahstat
          Mar 24 at 11:10












          i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
          – rebrec
          Mar 24 at 16:24




          i made a mistake. Try Exec="xterm -e /home/alexis/Launcher/spyder.sh"
          – rebrec
          Mar 24 at 16:24












          same error "There was an error launching the application."
          – ahstat
          Mar 25 at 8:25




          same error "There was an error launching the application."
          – ahstat
          Mar 25 at 8:25

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1018253%2flaunching-script-containing-virtual-env-through-desktop-icon%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491