Python script won't run on keyboard shortcut












3















So i have plenty of scripts which i run from keyboard shortcuts, things like uploading screenshots to imgur and putting links in the clipboard, stuff for digitising plots, etc.



I have this current script, which only runs from the terminal, and not when i try to run it as a keyboard shortcut.



I'm trying to run it via the System > Preferences > Keyboard Shortcuts on Scientific linux 6.4.



I've included the script below, in case there's anything specific about it which would stop it from working.



#!/usr/bin/python
import fileinput, os

import subprocess

from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer
import pygments.formatters as formatters

#stdin = "n".join([line for line in fileinput.input()])

p = subprocess.Popen(["xclip", "-selection", "primary", "-o"], stdout=subprocess.PIPE)
code, err = p.communicate()

if not err:

lexer = guess_lexer(code)

print lexer.name

imageformatter = formatters.ImageFormatter(linenos=True, cssclass="source", font_name="Liberation Mono")
formatter = formatters.HtmlFormatter(linenos=True, cssclass="source")

HTMLresult = highlight(code, lexer, formatter)
Jpgresult = highlight(code, lexer, imageformatter, outfile=open("syntax.png", "w"))

with open("syntax.html", "w") as f:

f.write("<html><head><style media='screen' type='text/css'>")
f.write(formatters.HtmlFormatter().get_style_defs('.source'))
f.write("</style></head><body>")
f.write(HTMLresult)
f.write("</body></html>")


# os.system("pdflatex syntax.tex")

os.system("firefox syntax.html")

os.system("uploadImage.sh syntax.png")



else:
print err


The way it works, is by extracting the clipboard selection using xclip, using pygments on the text, and then both creating an html document and opening it in firefox, and uploading an image to imgur (using another script i have, which i know 100% works), and then putting that image url back into the clipboard.



The bin folder it resides in is in my path.



I've tried all of:



script
script.sh (where this file is just a shell script which calls the python script)
/home/will/bin/script
/home/will/bin/script.sh


as the command in the keyboard preferences.



If i change the contents of these scripts to just something like notify-send "hello", and that then produces the notification message, so i'm fairlyconfident it's a probelm with the script, and not the keyboard shortcuts menu.










share|improve this question























  • I would place that notify-send "hello" to various places in the script to isolate exact line causing problems. Then you can move on. Maybe some part of your script needs some environlent you do not have when script is called via keyboard shortcut?

    – jhutar
    Nov 14 '14 at 20:56






  • 1





    Another important thing would be to try to capture output of your script. If you have wrapper script.sh, you can try to redirect stdout and stderr (and everithng else) to file via something like /home/will/bin/problematic_script.py &>/tmp/script.log. Maybe this will provide more clues?

    – jhutar
    Nov 14 '14 at 20:58
















3















So i have plenty of scripts which i run from keyboard shortcuts, things like uploading screenshots to imgur and putting links in the clipboard, stuff for digitising plots, etc.



I have this current script, which only runs from the terminal, and not when i try to run it as a keyboard shortcut.



I'm trying to run it via the System > Preferences > Keyboard Shortcuts on Scientific linux 6.4.



I've included the script below, in case there's anything specific about it which would stop it from working.



#!/usr/bin/python
import fileinput, os

import subprocess

from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer
import pygments.formatters as formatters

#stdin = "n".join([line for line in fileinput.input()])

p = subprocess.Popen(["xclip", "-selection", "primary", "-o"], stdout=subprocess.PIPE)
code, err = p.communicate()

if not err:

lexer = guess_lexer(code)

print lexer.name

imageformatter = formatters.ImageFormatter(linenos=True, cssclass="source", font_name="Liberation Mono")
formatter = formatters.HtmlFormatter(linenos=True, cssclass="source")

HTMLresult = highlight(code, lexer, formatter)
Jpgresult = highlight(code, lexer, imageformatter, outfile=open("syntax.png", "w"))

with open("syntax.html", "w") as f:

f.write("<html><head><style media='screen' type='text/css'>")
f.write(formatters.HtmlFormatter().get_style_defs('.source'))
f.write("</style></head><body>")
f.write(HTMLresult)
f.write("</body></html>")


# os.system("pdflatex syntax.tex")

os.system("firefox syntax.html")

os.system("uploadImage.sh syntax.png")



else:
print err


The way it works, is by extracting the clipboard selection using xclip, using pygments on the text, and then both creating an html document and opening it in firefox, and uploading an image to imgur (using another script i have, which i know 100% works), and then putting that image url back into the clipboard.



The bin folder it resides in is in my path.



I've tried all of:



script
script.sh (where this file is just a shell script which calls the python script)
/home/will/bin/script
/home/will/bin/script.sh


as the command in the keyboard preferences.



If i change the contents of these scripts to just something like notify-send "hello", and that then produces the notification message, so i'm fairlyconfident it's a probelm with the script, and not the keyboard shortcuts menu.










share|improve this question























  • I would place that notify-send "hello" to various places in the script to isolate exact line causing problems. Then you can move on. Maybe some part of your script needs some environlent you do not have when script is called via keyboard shortcut?

    – jhutar
    Nov 14 '14 at 20:56






  • 1





    Another important thing would be to try to capture output of your script. If you have wrapper script.sh, you can try to redirect stdout and stderr (and everithng else) to file via something like /home/will/bin/problematic_script.py &>/tmp/script.log. Maybe this will provide more clues?

    – jhutar
    Nov 14 '14 at 20:58














3












3








3








So i have plenty of scripts which i run from keyboard shortcuts, things like uploading screenshots to imgur and putting links in the clipboard, stuff for digitising plots, etc.



I have this current script, which only runs from the terminal, and not when i try to run it as a keyboard shortcut.



I'm trying to run it via the System > Preferences > Keyboard Shortcuts on Scientific linux 6.4.



I've included the script below, in case there's anything specific about it which would stop it from working.



#!/usr/bin/python
import fileinput, os

import subprocess

from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer
import pygments.formatters as formatters

#stdin = "n".join([line for line in fileinput.input()])

p = subprocess.Popen(["xclip", "-selection", "primary", "-o"], stdout=subprocess.PIPE)
code, err = p.communicate()

if not err:

lexer = guess_lexer(code)

print lexer.name

imageformatter = formatters.ImageFormatter(linenos=True, cssclass="source", font_name="Liberation Mono")
formatter = formatters.HtmlFormatter(linenos=True, cssclass="source")

HTMLresult = highlight(code, lexer, formatter)
Jpgresult = highlight(code, lexer, imageformatter, outfile=open("syntax.png", "w"))

with open("syntax.html", "w") as f:

f.write("<html><head><style media='screen' type='text/css'>")
f.write(formatters.HtmlFormatter().get_style_defs('.source'))
f.write("</style></head><body>")
f.write(HTMLresult)
f.write("</body></html>")


# os.system("pdflatex syntax.tex")

os.system("firefox syntax.html")

os.system("uploadImage.sh syntax.png")



else:
print err


The way it works, is by extracting the clipboard selection using xclip, using pygments on the text, and then both creating an html document and opening it in firefox, and uploading an image to imgur (using another script i have, which i know 100% works), and then putting that image url back into the clipboard.



The bin folder it resides in is in my path.



I've tried all of:



script
script.sh (where this file is just a shell script which calls the python script)
/home/will/bin/script
/home/will/bin/script.sh


as the command in the keyboard preferences.



If i change the contents of these scripts to just something like notify-send "hello", and that then produces the notification message, so i'm fairlyconfident it's a probelm with the script, and not the keyboard shortcuts menu.










share|improve this question














So i have plenty of scripts which i run from keyboard shortcuts, things like uploading screenshots to imgur and putting links in the clipboard, stuff for digitising plots, etc.



I have this current script, which only runs from the terminal, and not when i try to run it as a keyboard shortcut.



I'm trying to run it via the System > Preferences > Keyboard Shortcuts on Scientific linux 6.4.



I've included the script below, in case there's anything specific about it which would stop it from working.



#!/usr/bin/python
import fileinput, os

import subprocess

from pygments import highlight
from pygments.lexers import get_lexer_by_name, guess_lexer
import pygments.formatters as formatters

#stdin = "n".join([line for line in fileinput.input()])

p = subprocess.Popen(["xclip", "-selection", "primary", "-o"], stdout=subprocess.PIPE)
code, err = p.communicate()

if not err:

lexer = guess_lexer(code)

print lexer.name

imageformatter = formatters.ImageFormatter(linenos=True, cssclass="source", font_name="Liberation Mono")
formatter = formatters.HtmlFormatter(linenos=True, cssclass="source")

HTMLresult = highlight(code, lexer, formatter)
Jpgresult = highlight(code, lexer, imageformatter, outfile=open("syntax.png", "w"))

with open("syntax.html", "w") as f:

f.write("<html><head><style media='screen' type='text/css'>")
f.write(formatters.HtmlFormatter().get_style_defs('.source'))
f.write("</style></head><body>")
f.write(HTMLresult)
f.write("</body></html>")


# os.system("pdflatex syntax.tex")

os.system("firefox syntax.html")

os.system("uploadImage.sh syntax.png")



else:
print err


The way it works, is by extracting the clipboard selection using xclip, using pygments on the text, and then both creating an html document and opening it in firefox, and uploading an image to imgur (using another script i have, which i know 100% works), and then putting that image url back into the clipboard.



The bin folder it resides in is in my path.



I've tried all of:



script
script.sh (where this file is just a shell script which calls the python script)
/home/will/bin/script
/home/will/bin/script.sh


as the command in the keyboard preferences.



If i change the contents of these scripts to just something like notify-send "hello", and that then produces the notification message, so i'm fairlyconfident it's a probelm with the script, and not the keyboard shortcuts menu.







python linux bash keyboard-shortcuts redhat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 4 '14 at 11:58









willwill

6,22642752




6,22642752













  • I would place that notify-send "hello" to various places in the script to isolate exact line causing problems. Then you can move on. Maybe some part of your script needs some environlent you do not have when script is called via keyboard shortcut?

    – jhutar
    Nov 14 '14 at 20:56






  • 1





    Another important thing would be to try to capture output of your script. If you have wrapper script.sh, you can try to redirect stdout and stderr (and everithng else) to file via something like /home/will/bin/problematic_script.py &>/tmp/script.log. Maybe this will provide more clues?

    – jhutar
    Nov 14 '14 at 20:58



















  • I would place that notify-send "hello" to various places in the script to isolate exact line causing problems. Then you can move on. Maybe some part of your script needs some environlent you do not have when script is called via keyboard shortcut?

    – jhutar
    Nov 14 '14 at 20:56






  • 1





    Another important thing would be to try to capture output of your script. If you have wrapper script.sh, you can try to redirect stdout and stderr (and everithng else) to file via something like /home/will/bin/problematic_script.py &>/tmp/script.log. Maybe this will provide more clues?

    – jhutar
    Nov 14 '14 at 20:58

















I would place that notify-send "hello" to various places in the script to isolate exact line causing problems. Then you can move on. Maybe some part of your script needs some environlent you do not have when script is called via keyboard shortcut?

– jhutar
Nov 14 '14 at 20:56





I would place that notify-send "hello" to various places in the script to isolate exact line causing problems. Then you can move on. Maybe some part of your script needs some environlent you do not have when script is called via keyboard shortcut?

– jhutar
Nov 14 '14 at 20:56




1




1





Another important thing would be to try to capture output of your script. If you have wrapper script.sh, you can try to redirect stdout and stderr (and everithng else) to file via something like /home/will/bin/problematic_script.py &>/tmp/script.log. Maybe this will provide more clues?

– jhutar
Nov 14 '14 at 20:58





Another important thing would be to try to capture output of your script. If you have wrapper script.sh, you can try to redirect stdout and stderr (and everithng else) to file via something like /home/will/bin/problematic_script.py &>/tmp/script.log. Maybe this will provide more clues?

– jhutar
Nov 14 '14 at 20:58












4 Answers
4






active

oldest

votes


















2














I ran into exactly the same issue. Here's how I fixed it:



First of all, I wrote a one-liner shell script that looked something like python /home/user/Scripts/script.py where "/home/user/Scripts/script.py" was the location of my Python. I placed this shell script in the executable path.



Next, when I went to make my shortcut, I didn't tell the computer to run the file. I told the computer to start a terminal and gave the shell script as an argument to that terminal. In my case, it looked something like:xfce4-terminal -x ralia.sh.



This works for me.






share|improve this answer
























  • I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

    – will
    Jul 10 '15 at 9:52






  • 1





    ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

    – Cole Webb
    Jul 11 '15 at 4:04





















0














A possible issue is $PATH being different between your interactive shell and the environment of the daemon or program that handles keyboard shortcuts.



Try right after "import os":



open("/tmp/debug.txt", "w").write(os.environ["PATH"])


Then run it with the keyboard shortcut and look at /tmp/debug.txt.



→ Try absolute paths for the binaries and if that doesn't help, consider jhutar's advice.






share|improve this answer
























  • I have other scripts i run in exactly the same way in the same folder, and they work fine though.

    – will
    Mar 11 '15 at 21:43



















0














The problem is in "with open("syntax.html", "w") as f:".
When using keyboard shortcuts for the script, use full path of the files in the script.



Instead of:



with open("syntax.html", "w") as f:


Use:



with open("/home/user/my_script_folder/syntax.html", "w") as f:


Change all filenames in your script to full path and it should work.






share|improve this answer

































    0














    I have had a similar issue. The problem is that it is necessary to use full paths to make it work using keyboard shortcuts.



    In my case, this did not work:



    #!/bin/bash
    python scrypt.py


    However, this did work:



    #!/bin/bash
    python /home/user/bin/scrypt.py





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      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',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26734591%2fpython-script-wont-run-on-keyboard-shortcut%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      I ran into exactly the same issue. Here's how I fixed it:



      First of all, I wrote a one-liner shell script that looked something like python /home/user/Scripts/script.py where "/home/user/Scripts/script.py" was the location of my Python. I placed this shell script in the executable path.



      Next, when I went to make my shortcut, I didn't tell the computer to run the file. I told the computer to start a terminal and gave the shell script as an argument to that terminal. In my case, it looked something like:xfce4-terminal -x ralia.sh.



      This works for me.






      share|improve this answer
























      • I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

        – will
        Jul 10 '15 at 9:52






      • 1





        ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

        – Cole Webb
        Jul 11 '15 at 4:04


















      2














      I ran into exactly the same issue. Here's how I fixed it:



      First of all, I wrote a one-liner shell script that looked something like python /home/user/Scripts/script.py where "/home/user/Scripts/script.py" was the location of my Python. I placed this shell script in the executable path.



      Next, when I went to make my shortcut, I didn't tell the computer to run the file. I told the computer to start a terminal and gave the shell script as an argument to that terminal. In my case, it looked something like:xfce4-terminal -x ralia.sh.



      This works for me.






      share|improve this answer
























      • I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

        – will
        Jul 10 '15 at 9:52






      • 1





        ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

        – Cole Webb
        Jul 11 '15 at 4:04
















      2












      2








      2







      I ran into exactly the same issue. Here's how I fixed it:



      First of all, I wrote a one-liner shell script that looked something like python /home/user/Scripts/script.py where "/home/user/Scripts/script.py" was the location of my Python. I placed this shell script in the executable path.



      Next, when I went to make my shortcut, I didn't tell the computer to run the file. I told the computer to start a terminal and gave the shell script as an argument to that terminal. In my case, it looked something like:xfce4-terminal -x ralia.sh.



      This works for me.






      share|improve this answer













      I ran into exactly the same issue. Here's how I fixed it:



      First of all, I wrote a one-liner shell script that looked something like python /home/user/Scripts/script.py where "/home/user/Scripts/script.py" was the location of my Python. I placed this shell script in the executable path.



      Next, when I went to make my shortcut, I didn't tell the computer to run the file. I told the computer to start a terminal and gave the shell script as an argument to that terminal. In my case, it looked something like:xfce4-terminal -x ralia.sh.



      This works for me.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jul 9 '15 at 16:58









      Cole WebbCole Webb

      215




      215













      • I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

        – will
        Jul 10 '15 at 9:52






      • 1





        ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

        – Cole Webb
        Jul 11 '15 at 4:04





















      • I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

        – will
        Jul 10 '15 at 9:52






      • 1





        ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

        – Cole Webb
        Jul 11 '15 at 4:04



















      I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

      – will
      Jul 10 '15 at 9:52





      I'm not using that computer anymore, but if this really is a solution then it's a ridiculous one!

      – will
      Jul 10 '15 at 9:52




      1




      1





      ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

      – Cole Webb
      Jul 11 '15 at 4:04







      ridiculous? yes. does it work? yes. I did find a better way to do it. You can cut out the shell script middleman and put xfce4-terminal -x python /home/user/scripts/python_scripts.py on the launcher line instead.

      – Cole Webb
      Jul 11 '15 at 4:04















      0














      A possible issue is $PATH being different between your interactive shell and the environment of the daemon or program that handles keyboard shortcuts.



      Try right after "import os":



      open("/tmp/debug.txt", "w").write(os.environ["PATH"])


      Then run it with the keyboard shortcut and look at /tmp/debug.txt.



      → Try absolute paths for the binaries and if that doesn't help, consider jhutar's advice.






      share|improve this answer
























      • I have other scripts i run in exactly the same way in the same folder, and they work fine though.

        – will
        Mar 11 '15 at 21:43
















      0














      A possible issue is $PATH being different between your interactive shell and the environment of the daemon or program that handles keyboard shortcuts.



      Try right after "import os":



      open("/tmp/debug.txt", "w").write(os.environ["PATH"])


      Then run it with the keyboard shortcut and look at /tmp/debug.txt.



      → Try absolute paths for the binaries and if that doesn't help, consider jhutar's advice.






      share|improve this answer
























      • I have other scripts i run in exactly the same way in the same folder, and they work fine though.

        – will
        Mar 11 '15 at 21:43














      0












      0








      0







      A possible issue is $PATH being different between your interactive shell and the environment of the daemon or program that handles keyboard shortcuts.



      Try right after "import os":



      open("/tmp/debug.txt", "w").write(os.environ["PATH"])


      Then run it with the keyboard shortcut and look at /tmp/debug.txt.



      → Try absolute paths for the binaries and if that doesn't help, consider jhutar's advice.






      share|improve this answer













      A possible issue is $PATH being different between your interactive shell and the environment of the daemon or program that handles keyboard shortcuts.



      Try right after "import os":



      open("/tmp/debug.txt", "w").write(os.environ["PATH"])


      Then run it with the keyboard shortcut and look at /tmp/debug.txt.



      → Try absolute paths for the binaries and if that doesn't help, consider jhutar's advice.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Mar 11 '15 at 21:32









      wfrwfr

      511310




      511310













      • I have other scripts i run in exactly the same way in the same folder, and they work fine though.

        – will
        Mar 11 '15 at 21:43



















      • I have other scripts i run in exactly the same way in the same folder, and they work fine though.

        – will
        Mar 11 '15 at 21:43

















      I have other scripts i run in exactly the same way in the same folder, and they work fine though.

      – will
      Mar 11 '15 at 21:43





      I have other scripts i run in exactly the same way in the same folder, and they work fine though.

      – will
      Mar 11 '15 at 21:43











      0














      The problem is in "with open("syntax.html", "w") as f:".
      When using keyboard shortcuts for the script, use full path of the files in the script.



      Instead of:



      with open("syntax.html", "w") as f:


      Use:



      with open("/home/user/my_script_folder/syntax.html", "w") as f:


      Change all filenames in your script to full path and it should work.






      share|improve this answer






























        0














        The problem is in "with open("syntax.html", "w") as f:".
        When using keyboard shortcuts for the script, use full path of the files in the script.



        Instead of:



        with open("syntax.html", "w") as f:


        Use:



        with open("/home/user/my_script_folder/syntax.html", "w") as f:


        Change all filenames in your script to full path and it should work.






        share|improve this answer




























          0












          0








          0







          The problem is in "with open("syntax.html", "w") as f:".
          When using keyboard shortcuts for the script, use full path of the files in the script.



          Instead of:



          with open("syntax.html", "w") as f:


          Use:



          with open("/home/user/my_script_folder/syntax.html", "w") as f:


          Change all filenames in your script to full path and it should work.






          share|improve this answer















          The problem is in "with open("syntax.html", "w") as f:".
          When using keyboard shortcuts for the script, use full path of the files in the script.



          Instead of:



          with open("syntax.html", "w") as f:


          Use:



          with open("/home/user/my_script_folder/syntax.html", "w") as f:


          Change all filenames in your script to full path and it should work.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 '17 at 18:50

























          answered Nov 12 '17 at 18:44









          Vignesh ArunachalamVignesh Arunachalam

          12




          12























              0














              I have had a similar issue. The problem is that it is necessary to use full paths to make it work using keyboard shortcuts.



              In my case, this did not work:



              #!/bin/bash
              python scrypt.py


              However, this did work:



              #!/bin/bash
              python /home/user/bin/scrypt.py





              share|improve this answer




























                0














                I have had a similar issue. The problem is that it is necessary to use full paths to make it work using keyboard shortcuts.



                In my case, this did not work:



                #!/bin/bash
                python scrypt.py


                However, this did work:



                #!/bin/bash
                python /home/user/bin/scrypt.py





                share|improve this answer


























                  0












                  0








                  0







                  I have had a similar issue. The problem is that it is necessary to use full paths to make it work using keyboard shortcuts.



                  In my case, this did not work:



                  #!/bin/bash
                  python scrypt.py


                  However, this did work:



                  #!/bin/bash
                  python /home/user/bin/scrypt.py





                  share|improve this answer













                  I have had a similar issue. The problem is that it is necessary to use full paths to make it work using keyboard shortcuts.



                  In my case, this did not work:



                  #!/bin/bash
                  python scrypt.py


                  However, this did work:



                  #!/bin/bash
                  python /home/user/bin/scrypt.py






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 26 '18 at 12:15









                  D. MoralesD. Morales

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26734591%2fpython-script-wont-run-on-keyboard-shortcut%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                      Calculate evaluation metrics using cross_val_predict sklearn

                      Insert data from modal to MySQL (multiple modal on website)