1

I don't know how to open a .py file in the interpreter. When I double click it, it opens in gedit. Can you help?

1
  • At the top, there should be a coulmn called Run. If it's not there, you could press F5. I will add this as a question if it works.
    – horIzoN
    Mar 25, 2013 at 16:23

3 Answers 3

1

You probably don't have the executable bit set on the script.

  1. Right click on the file.
  2. Click on Properties.
  3. On the Permission tab, check “Allow executing file as program.”
2
  • I guess you would just click on the file again.
    – horIzoN
    Mar 25, 2013 at 16:39
  • Ok, clicked run in terminal.
    – V360
    Mar 25, 2013 at 16:40
1

In case we want to read any output of the python application, e.g. for debugging or if it is a terminal based script, it may be better to run this python script not in the background by double-clicking but from the interpreter in a terminal.

To do so issue the following commands:

cd /path/to/script.py
python script.py

The script does not need executable permissions to run from the python interpreter in a terminal.

Python3 applications are run with the following command:

python3 script.py
0

The easiest way to do so is to type #!usr/bin/python on the first line of your code. This will automatically call up the python interpreter when you double click on the file. P.S. - The path is for python 2.7 and not for python3 you would have to look up the path for your python 3.XX yourself in your system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .