I'm learning python so I may get my foot in the door for a programming career. I'm using the gedit text editor to write the code, however I don't know how to execute the code on ubuntu. If anyone is able to help, I would greatly appreciate as much help as I'm able to get.
Asked
Active
Viewed 3.3k times
1
1 Answers
4
Open a terminal by pressing CtrlAltT. If you remember where you saved the Python code file (say as first.py
in the Desktop
folder), use the following command to run it:
python2 ~/Desktop/first.py
If you're using Python 3.X replace python2
with python3
in the above command. On Ubuntu, python2
and python
are the same, but it's always good practice to explicitly specify which version you're using.
You can also simply run python2
or python3
to get to an interactive shell. Another option is to use IPython Notebooks.

muru
- 197,895
- 55
- 485
- 740
-
I just tried to run it and I got this error: python3: can't open file 'Desktop/leaningpython.py': [Errno 2] No such file or directory – Sean Kirkland Sep 09 '14 at 23:24
-
yes it's on my desktop that is usually where I save my documents until I move them into another folder – Sean Kirkland Sep 09 '14 at 23:28
-
OK, try:
python3 ~/Desktop/leaningpython.py
. Also, please post the output ofls ~/Desktop -l
. – muru Sep 09 '14 at 23:28 -
as I run it all I'm getting is this: File "/home/darkxearo/Desktop/learningpython.py", line 1 >>> "This text really won't do anything" ^ SyntaxError: invalid syntax – Sean Kirkland Sep 09 '14 at 23:32
-
2@SeanKirkland there you have it. You haven't written valid Python code yet. :) – muru Sep 09 '14 at 23:33
-
-
cd
,ls
, etc.? – muru Sep 09 '14 at 23:09python3
. They broke the status quo and I think forced this recommendation. Fedora also intend to migrate soon, I think. – muru Sep 10 '14 at 12:56