LPTHW Excise 1 opening file in terminal

Hello,

I’m using MacOS and I’m not able to open my first exercise. Can you please help?
MacBook-Air:~ aka2d7$ cd lpthw
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ex1.py
-bash: ex1.py: command not found
MacBook-Air:lpthw aka2d7$ pwd
/Users/aka2d7/lpthw
MacBook-Air:lpthw aka2d7$ /document/Linda/lpthw/
-bash: /document/Linda/lpthw/: No such file or directory
MacBook-Air:lpthw aka2d7$ cd …
MacBook-Air:~ aka2d7$ python3.6 ex1.py
/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘ex1.py’: [Errno 2] No such file or directory
MacBook-Air:~ aka2d7$ cd /Document/Linda/lpthw/
-bash: cd: /Document/Linda/lpthw/: No such file or directory
MacBook-Air:~ aka2d7$ pwd
/Users/aka2d7
MacBook-Air:~ aka2d7$ ls
I Have Fun Movies
Applications Music
Desktop Pictures
Documents Public
Downloads Things To Do 8:12:2012.txt
Dropbox Things To Do.txt
Google Drive dl.txt
Home goods.txt lpthw
House Renovations.txt snapshot.png
Library temp
MacBook-Air:~ aka2d7$ pwd
/Users/aka2d7
MacBook-Air:~ aka2d7$ cd Document/Linda/lpthw
-bash: cd: Document/Linda/lpthw: No such file or directory
MacBook-Air:~ aka2d7$ cd lpthw
MacBook-Air:lpthw aka2d7$ ex1.py
-bash: ex1.py: command not found
MacBook-Air:lpthw aka2d7$ python3.6 python/ex1.py
/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘python/ex1.py’: [Errno 2] No such file or directory
MacBook-Air:lpthw aka2d7$ python3.6 /users/aka2d7/document/Linda/lpthw/ex1.py
/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘/users/aka2d7/document/Linda/lpthw/ex1.py’: [Errno 2] No such file or directory
MacBook-Air:lpthw aka2d7$

When you cd to the lpthw directory, do:
python3.6 ex1.py

lo_lo,

Here is what I got.

MacBook-Air:~ aka2d7$ cd lpthw
MacBook-Air:lpthw aka2d7$ python3.6 ex1.py
/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘ex1.py’: [Errno 2] No such file or directory
MacBook-Air:lpthw aka2d7$ python ex1.py
python: can’t open file ‘ex1.py’: [Errno 2] No such file or directory
MacBook-Air:lpthw aka2d7$

what am I missing?
Thanks,
aka2d7

If you are in the lpthw directory and do:
ls
can you see ex1.py?

No, I’m not seeing the file.
MacBook-Air:/ aka2d7$ cd
MacBook-Air:~ aka2d7$ cd lpthw
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ls
MacBook-Air:lpthw aka2d7$ ex1.py
-bash: ex1.py: command not found
MacBook-Air:lpthw aka2d7$

Well then where is your ex1.py? on the Desktop? or where did you saved it?
You need to put it inside the lpthw directory then do:
python3.6 ex1.py

This is the path
/Users/aka2d7/Documents/Linda/lpthw/ex1.py

so it is inside the lpthw directory…
but if you look above, when you changed directory you did: cd Document/Linda/lpthw and your path is
Documents/Linda/lpthw.
You forgot an s at the end of Documents.
These details are really important and soon you will get used to it.
Did you read the Command line crash course to see what these commands do?
This chapter is in the book.
Ok, so in your terminal you do exactly this:

  1. cd ~/Documents/Linda/lpthw
  2. ls (you should see ex1.py)
  3. python3.6 ex1.py

Hi lo_lo

Your absolutely correct! i appreciate this help and support. I have been working on the Command Line Crash Course and just about done with it but will need to go back through it again. What is the (~) sign because I haven’t see that used before?

Again! I really appreciate your help… I’m so excited to see these exercises working that I need to slow down to really understand what I’m doing.

Thanks,
aka2d7

Well, ~/ is the shortcut for /home directory. The equal of your /Users/aka2d7/.
No matter the black hole you are lost in, if you know the directory you want to go to is in your home directory, you do ~/ followed by the directory you want to go to.
There’s no such thing as a black hole though if you find out where exactly you are with pwd (print working directory).
But I know the feeling of not being familiar with the command line.
Been there too, of course :smile:
So get to know your terminal, get to know where the directories are placed in your computer, learn that appendix and play more with the commands you learn from it.

ok, thanks great advice!

Thanks for the help @io_io!

1 Like