First Day Python Trouble: Having Trouble Connecting Python with Atom

! I am having a lot of trouble trying to run python through the terminal and I know this is a very rookie mistake but I feel like I have tried everything. Anyone who can help a noob out it will be much appreciated. Thank you

Well there are 2 ways you can run that code.

  1. You can let it in that file you have it. Save the file as ex1.py
    Then get out of the Python interpreter and in the same directory with your exercise (cd there) run it with python or python3 or python3.6 or python3.7 like so:
    python ex1.py where python is your version of python.
  2. You write it again from the start in the interpreter then press Enter.
    Look closely, Zed says it:

Your file is not called ex1.py because you forgot to save it.

I got my atom to work and it says python but when it comes to connecting to the terminal it does not copy what I am typing. Is this a big deal if my terminal is not keeping up with what I am typing in at atom?

You have a bit of misunderstanding here I am afraid. No bother as it is part of learning.

The terminal is like a little doorway into controlling your computer, but not with the user interface (UI) that Bill Gates and Windows made really popular. In the old days you didn’t have windows you could click and drag about, double-clicking on things and using menus to copy or save. It was all done with typed commands. Terminal is that. It’s very power and a little intimidating.

You can run Python from the terminal by typing ‘Python’. It runs the program in a special embedded way that executed python like in the book.

Atom, Visual Code and other Editors are really just like MS Word, TextEdit or other document tools, but designed specifically for working with code. All you do is write text, but in a coding style and save it. No different from writing a word document or email really.

The key is that you can use the terminal to run the file you just saved. (In fact you can also do it from Atom/VS too). This is done by telling the computer to run python and pass it the file you saved:

python ex1.py

Running the saved files like this is useful as you get a lot of useful info from terminal when things go wrong.

The alternative is writing it all in the terminal which is prone to error as you kind of have one take to get it right.

Basically, they are different things. Imagine writing an email in your email client and saving it. But having to use terminal to tell the computer to ‘send’ and await the response to save “message sent” or “message failed: unknown recipient”.

From your screencap, you might want to try navigating into your directory before running your python file. So:

$ cd Users/chef
$ ls   --> helps to see if you're in the right directory
$ python 3.7 exercise1.py

Also:

  1. Have you saved your file? (the blue dot on your tab means your changes haven’t been saved)
  2. Have you ended your python session in terminal (Ctrl-C in Mac) and then restarted it after saving your changes?

So you typed this:

/Users/chef python3.7 exercise1.py

If I read that it’s “Users chef python three point seven exercise one py”. Now, look at how I run it:

python3.7 ex1.py

If I read that it’s “python three seven ex1.py”.

You’re typing a whole path in front of what you type, but I just type that command. Now, this makes me think a couple things:

  1. Did you watch the video? I do this on OSX so you can see what I type. Slow it down and pause to watch me do it.
  2. Did you go through Appendix A to get familiar with the command line?

I believe two misunderstandings are happening here:

  1. You are seeing the /Users/zed part of the screen in my screenshots or videos, but that is not typed by me. My computer prints that out so I know where I am at. I just type the things after the $.
  2. Looking at your path in your Atom, you are saving the files into Desktop/exercise files, but then you don’t cd into that directory to run your code. That’s what you learn in Appendix A.

When you go through appendix A I want you to religiously type these two commands religiously like your life depends on it:

pwd
ls

That will help you get this figured out, and you’ll see how this works after you do Appendix A.