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?
3 Answers
You probably don't have the executable bit set on the script.
- Right click on the file.
- Click on Properties.
- On the Permission tab, check “Allow executing file as program.”
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
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.
Run
. If it's not there, you could press F5. I will add this as a question if it works.