Unable to execute Python Script directly

41 views Asked by At

I am unable to execute Python Script directly.

enter image description here

enter image description here

whereas path to Python Environemnt is as follows:

root@UbuntuDockerGuest-1:~# python -c "import os; print(os.environ['_'])"

/usr/bin/python

I am not sure how to add it correctly in the begining of the program?

Thank you.

Just want to test running python script directly

2

There are 2 answers

0
Mark Reed On

You have an extra blank line at the top of the file. The #! have to be the first two bytes of the file, no whitespace or newline before them.

Also, the path after the #! has to be /usr/bin/python or /usr/bin/env python, not /usr/bin python.

0
Ritvik The God On

Delete the line with the shebang.

Ctrl + K on:

#! usr / bin + python

Hit Save. You are done.

Now can run the .py script:

python <MyScript.py>

Give yourself a pat on the back for job well done!