2

Hello guys I'm actually new to Terminal and Python. Just started following a Python tuturial on my Ubuntu and I've reached a part where it asks me to save a .py file and open it in Terminal.

Only when I try to type on Terminal $ python egotrip.py I get $: command not found Then I try to type it in python and I get

File "", line 1
    python egotrip.py
                 ^
SyntaxError: invalid syntax

But I mean all names are correct :(

Then I gave also tried /home/anacah/Desktop/python/egotrip.py And I get

Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'home' is not defined

What am I doing wrong? :( can someone please help?

Thomas Ward
  • 78,878
Ana
  • 31

2 Answers2

3

Try using this line in the terminal:
python /home/anacah/Desktop/python/egotrip.py

thereby providing the entire path for the file including the / at the beginning, and see what happens. If it errors out, please edit your initial post with the section 'Additional Information' and paste the error message.

Thomas Ward
  • 78,878
2

Change directories to the folder where your .py file is stored. Your command should look like this:

cd /home/anacah/Desktop/python 

From your information above, it looks as if you left out the cd command. Once in that folder, just type:

python egotrip.py

and it should work!

snoop
  • 4,110
  • 9
  • 41
  • 58