Error in Importing a bash script into a python

I am trying to create a python script in bash and importing a bash script.

#!/usr/bin/env python    
import os
import glob
from fnmatch import fnmatch
# importing a software
python_package = os.system("""#!/path_to_bin/bin/python \
from __future__ import print_function, division \
from python_toolbox.toolbox.some_toolbox import run \
if __name__ == '__main__': \

# testing 
greeting = "Hello world!"

Running the in python3

  File "", line 15
    greeting = "Hello world!"
SyntaxError: invalid syntax

>Solution :

Nominally the problem is that you are missing the closing paren on the os.system call. But there is a better way to run a python program than trying to write it all on the command line. Instead, you can pass a full script, including newlines, to python’s stdin.

#!/usr/bin/env python    
import sys
import subprocess as subp

# importing a software[sys.executable, "-"], input=b"""
print("I am a called python script")

# testing 
greeting = "Hello world!"

Leave a Reply