Python Forum
Run .py file in Kali Linux Terminal - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Run .py file in Kali Linux Terminal (/thread-16408.html)



Run .py file in Kali Linux Terminal - grayarea3 - Feb-27-2019

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!


RE: Run .py file in Kali Linux Terminal - woooee - Feb-27-2019

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



RE: Run .py file in Kali Linux Terminal - grayarea3 - Feb-27-2019

Now I'm getting the error "NameError: name 'python' is not defined.


RE: Run .py file in Kali Linux Terminal - woooee - Feb-27-2019

First print the PATH, echo $PATH. This is where the OS searches for programs. Python has to be installed in one of these locations.


RE: Run .py file in Kali Linux Terminal - buran - Feb-27-2019

(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 >>>?