Python Forum

Full Version: Run .py file in Kali Linux Terminal
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I run a .py file in the Kali Linux terminal?

I changed my directory to the directory containing my file, used the chmod a+x <myfilename> command, and then used the ./<myfilename> command. All I get is a blank line with no output. I would be grateful for any suggestions!
Does your program print anything for you to see? Do you have a shebang on the first line? Try running it as
Quote:python ./filename.py
Now I'm getting the error "NameError: name 'python' is not defined.
First print the PATH, echo $PATH. This is where the OS searches for programs. Python has to be installed in one of these locations.
(Feb-27-2019, 04:41 AM)grayarea3 Wrote: [ -> ]Now I'm getting the error "NameError: name 'python' is not defined.
NameError suggest you are already in python environment.
Wild guess - you are trying to run it in interactive mode. Or you have shebang in the file that's not correct somehow
do you see >>>?