1

How do I run a simple python program in fedora?

I am very much new to fedora and i don't know how exactly to start in fedora. Do we need to install any software in fedora to make python programs work? Please tell me step by step how to do it. I am familiar with IDLE but not in fedora.

0

2 Answers 2

7

Put

#!/usr/bin/env python

at the top of your file. Then on the command line do

$ chmod u+x your_python_file.py

(I use $ to indicate a shell prompt, don't type that.) You can run the file with

$ ./yourpythonfile.py

You can also just do

$ python yourpythonfile.py

and don't need the #!/usr.... or $ chmod ... stuff, but the first approach is the natural way to do things in unix.

4
  • 1
    +1. And if Python isn't installed, run yum install python from a shell (command-line) with root privileges.
    – Cameron
    Oct 20, 2011 at 16:16
  • or sudo yum install and then enter your super user password. I am pretty sure python ships with all the major linux distros though.
    – Paul
    Oct 20, 2011 at 16:18
  • 2
    @Cameron This doesn't make much sense as yum depends on python :)
    – rplnt
    Oct 20, 2011 at 16:22
  • how can i know which python libraries are there in my fedora's python?and how to add more library if i want to add.can i know which version of python is installed in fedora?help me out plz
    – Sumit Raj
    Oct 21, 2011 at 17:58
1

In Fedora python is already installed. Just run in the command line:

 python ./yourProgram.py
2
  • how can i know which python libraries are there in my fedora's python?and how to add more library if i want to add.can i know which version of python is installed in fedora?help me out plz
    – Sumit Raj
    Oct 21, 2011 at 17:56
  • python --version will give you the python version. I do not use Fedora so I do not know the exact path to the python libraries, but the path is stated in the man page of python.
    – tune2fs
    Oct 21, 2011 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.