Python Forum
Run .py file in Kali Linux Terminal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run .py file in Kali Linux Terminal
#1
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!
Reply
#2
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
Reply
#3
Now I'm getting the error "NameError: name 'python' is not defined.
Reply
#4
First print the PATH, echo $PATH. This is where the OS searches for programs. Python has to be installed in one of these locations.
Reply
#5
(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 >>>?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  create exe file for linux? korenron 2 911 Mar-22-2023, 01:42 PM
Last Post: korenron
  Python in Kali Linux coolcassie 2 7,137 Dec-02-2019, 12:48 PM
Last Post: coolcassie
  Want to take a Screenshot from a File in Linux dhiliptcs 2 2,518 Oct-21-2019, 01:22 PM
Last Post: dhiliptcs
  Coloured text in the terminal works in Linux but not Windows Flexico 2 2,667 Aug-26-2019, 10:44 PM
Last Post: Flexico
  Loops - new terminal output to file for each loop jm_ice 1 2,554 Dec-21-2018, 02:42 PM
Last Post: ichabod801
  New to Python-Unable to run a .py file in terminal AshishSangwan 3 3,416 Feb-15-2018, 02:49 PM
Last Post: AshishSangwan
  Print the file using the associated application on Linux Borisko 1 3,624 Oct-15-2017, 07:14 AM
Last Post: wavic
  Simple Post in Kali mgeorgevich5317 3 3,434 Sep-09-2017, 11:56 PM
Last Post: wavic
  .py to exe or to executable file for linux Low_Ki_ 4 9,794 Apr-26-2017, 05:59 AM
Last Post: Low_Ki_
  How do I accept input from the terminal when I execute my file? cocoa1231 1 4,083 Dec-08-2016, 11:22 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020