1

I am making a .Sh File which will in turn run a Python file cause I want that .Sh file to run in the background.

So here is the name of my Python File - canlp.py. And the .sh file code to run this Python file is as follows.

#!/bin/sh
CWD="$(pwd)"
python canlp.py

Although when I run this code it gives me this error in CMD - canlp.sh: line 3: python: command not found When I run it using bash canlp.sh

And I am able to run it from Standalone Terminal without using .Sh . I am using the latest version of Python and have Windows 10 as a Operating System

  • please add following details to question: 1. are you able to run it standalone from terminal? (without .sh) 2. which OS? Which python version are you using? Depending on OS the steps would vary. eg for windows: https://stackoverflow.com/questions/59125493/how-to-constantly-run-python-script-in-the-background-on-windows#:~:text=On%20Windows%2C%20you%20can%20use,the%20program%20uses%20a%20GUI. – Sahil Feb 25 '22 at 12:46
  • Did the changes now Sir – Jay shankarpure Feb 25 '22 at 12:48
  • what i mean by standalone is: If you just run "python canlp.py" from terminal (forget about .sh) does it run? If not, you have a larger problem worth solving 1st – Sahil Feb 25 '22 at 12:50
  • I misunderstood u sir , The .py file runs smoothly in the terminal , The issue is with .sh file – Jay shankarpure Feb 25 '22 at 12:51
  • 1
    You've tagged the question `bash` but you use `#!/bin/sh` as a she-bang. You'd better make that `#!/bin/bash` just to be sure that you actually run `bash` – Ted Lyngmo Feb 25 '22 at 12:51
  • Are you running this in `CMD`, `PowerShell` or `Ubuntu` (`bash` then I presume)? – Ted Lyngmo Feb 25 '22 at 12:56
  • I am using CMD sir – Jay shankarpure Feb 25 '22 at 12:58
  • Seeif this helps: https://www.howtogeek.com/285082/how-to-run-windows-programs-from-windows-10s-bash-shell/ My guess is that bash is unable to access the binary coz pointers to it aree not added to the right directories – Sahil Feb 25 '22 at 13:00
  • Read the article sir , Although tried using as mentioned in the article , Still the error remains the same – Jay shankarpure Feb 25 '22 at 13:07
  • Actually i have not used windows at all for development so not sure about how to help. One large suggestion i have is to use ubuntu if possible for development its muchmuch much more developer friendly. https://linuxhint.com/ubuntu-vs-windows/ – Sahil Feb 25 '22 at 13:15
  • @Jayshankarpure Can you run this [bash script](https://pastebin.com/QvFpKrC8) in CMD too? If there is a `python`, `python2` or `python3` installed (and in your PATH), it should find it. – Ted Lyngmo Feb 25 '22 at 13:22
  • Okay Sir , Will try using it – Jay shankarpure Feb 27 '22 at 15:34
  • Thanks Sahil Sir , Any idea how can i install ubuntu parallely in my Windows laptop – Jay shankarpure Feb 27 '22 at 15:35

0 Answers0