Setting up terminal for Python

I’ve tried typing mkdir lpthw and the terminal said that it was an invalid syntax. Do you guys know what’s wrong.

**

Thank you so so muchhhhh:heart_eyes::heart_eyes::heart_eyes::heart_eyes:

Hello @Rosellia.

There is no problem with your command "mkdir lpthw”. But it is a unix command.
So you cannot do this in a “python-terminal”. At least not that way.

Start your terminal (perhaps it is called ”console” in Mac).
Navigate to where you want to create this folder ”cd home/your_name/”
Create it with the command ”mkdir lpthw”
Then navigate in to it with ”cd lpthw”.
Now you can start to write your python files in here with your favourite text editor.

1 Like

Adding to this, usually when you run a python script, you’ll tell the terminal which software to run (i.e. Python) and then the file to execute.

python3.6 app.py

But many languages have built in ways to run the language directly in the terminal. When you just run

python3.6

You are telling the terminal to run that built-in interpreter. You can see it is running by the build numbers etc, and it usually starts with

>>>

As ulfen69 says, this is ‘inside’ python and not the normal command line where Unix commands will work.

1 Like

So, pretty common mistake and a few people gave you suggestions but I’ll explain a little differently:

  1. You have started your shell here on your macbook using the Terminal program.
  2. This Terminal program runs something called bash. If you don’t know how to use bash, jump to Appendix A and you’ll go through the Command Line Crash Course, then this will make a lot more sense.
  3. Now, in bash you typed python3.6 all on its own. This though runs Python, and then prints out >>> which is like saying “Type Python code here.”
  4. You then typed bash commands into the place where you are expected to type Python code and Python didn’t like it.
  5. The solution is to type quit(), hit ENTER, and you’ll be back at bash. It’s the ~ anchi$ prompt you see there. That’s where you type these bash commands.

You should also watch my video as I do this and it’s way easier to see someone work a bash shell than to read about what to do.

1 Like

Thank you so much. That was really easy to understand. May I ask where I can watch a video of you working on a bash shell?

Hi @Rosellia.

I guess you could login at Zed’s web site Learn Code The Hard Way and down load his videos that comes with the book.

You could also search for “bash mkdir” on Youtube.
You will get tons of results. Most of them are about Linux.
But you can use them in your Mac too. All of the basic commands are the same in Linux and Mac.

1 Like