1
Tamara-Lovs-MacBook-Pro:~ Tamara$
Tamara-Lovs-MacBook-Pro:~ Tamara$ 1+1
-bash: 1+1: command not found

That is what comes up when I open the terminal.

Tamara Lov is the name my Mac is registered under. I played around with some preferences but don't know to use it.

1 Answer 1

6

When you open your Terminal, you will land in a so-called shell. In this case, bash is the default shell which comes with OS X and it is started for you. Bash doesn't know the command 1+1.

To actually use python, you will have to start the python interpreter first. Do that with:

python

Now you can enter your live scripts.

enter image description here

If you write some scripts using a text editor, you can run them from bash by calling the following (for example, if your script is saved under Documents):

python /Users/Tamara/Documents/your-script.py
14
  • how do i open python? i thought the terminal automatically opens python.
    – tamara
    Nov 30, 2011 at 23:25
  • No. The terminal automatically opens a shell for you, which you can use to open python. Python is just a program like many many others, it wouldn't make sense for a terminal just to open Python. You open Python by entering python in your shell.
    – slhck
    Nov 30, 2011 at 23:27
  • 1
    @Tamara Comment are not a chat. We do have an actual chat room though, the link is at the very top of the page. Regarding your questions, consider reading up on the topic first. Your questions are both off topic on this site (we don't do programming questions outside a computer user context) and show a certain lack of understanding the basics – reading programming introductions will help you better than posting a string of trivial (for more advanced users) questions.
    – Daniel Beck
    Dec 1, 2011 at 6:25
  • 1
    @tamara > how can i change the variable after? also where do i write the code? – Please read a Python tutorial, as Daniel advised you. This is very basic programming. You normally write code from a text editor such as TextWrangler, save it to a file, and then execute this file with the python + filename command.
    – slhck
    Dec 1, 2011 at 19:33
  • 1
    @tamara You're using comments like a real-time chat, sending four where one would suffice, perhaps not knowing that slhck is separately informed about every one of them. I just try to make you aware of it and offer alternatives, both to the comments and your problem more generally. I've used Dive into Python a few years back and found it helpful. If my comment still comes across as rude, bear in mind that this is written communication only; and English is a second language for many users on this site, including me, and outside a school or web context, many haven't had the chance to use it.
    – Daniel Beck
    Dec 2, 2011 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .