'Windows: Unable to run a shell script in spyder (python 3.8). Invalid Syntax error [duplicate]
I am trying to run a shell script in Spyder (Python 3.8). I have tried the following and all this is giving me the same error - Invalid Syntax
bash ./filename.shbash filename.shsh filename.shsh ./filename.shshell ./filename.shshell filename.shimport subprocess subprocess.run(.\filename.sh)
source filename.sh
9.
import subprocess
subprocess.run(filename.sh)
The last one gives the error:
name 'filename' doesn't exist.
Note: I have rechecked my pwd.
Solution 1:[1]
Add quotes
subprocess.run("filename.sh")
Also, I would like to point out that unless you are using some package to add the syntax bash, sh, etc... you would get the syntax error since Python doesn't know what those keywords mean.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | M B |

