Search code examples
pythoncsysteminterpreter

Do we need to specify python interpreter externally if python script contains #!/usr/bin/python3?


I am trying to invoke python script from C application using system() call

The python script has #!/usr/bin/python3 on the first line.

If I do system(python_script), the script does not seem to run.

It seems I need to do system(/usr/bin/python3 python_script).

I thought I do not need to specify the interpreter externally if I have #!/usr/bin/python3 in the first line of the script.

Am I doing something wrong?


Solution

  • Make sure you have executable permission for python_script. You can make python_script executable by

    chmod +x python_script

    Also check if you are giving correct path for python_script