Sample Video Frame

Created by Zed A. Shaw Updated 2024-02-17 04:54:36

0: Gearing Up

This exercise has no code. It is simply the exercise you complete to get your computer to run Python. You should follow these instructions as exactly as possible. If you have problems following the written instructions, then watch the included videos for your platform.

General Instructions

Your general task is to get a "programming environment" with tools you can use to write code. Nearly every programmer has their own specialized environment, but at first you'll want something simple that can get you through this course. After the course you'll know enough about programming to then waste the rest of your life trying every tool you can imagine. It's a lot of fun.

What you'll need is the following, but don't install it yet. This is just a preview of what you'll install in a minute:

  1. Jupyter which will be used in the first part of the book to get you started easily. Jupyter is a programming and data analysis environment that uses many languages, but we'll use Python.
  2. Python. The version of Python you install mostly doesn’t matter so long as it’s newer than version 3.10. Versions of Python (and other software) use numbers to indicate their age, and the position of the numbers determines how much changed between versions. The general rule is the first number means “major change,” the second number means “compatible changes,” and a third number means only bug or security fixes. That means if you have version 3.8 and version 3.10, then they should be compatible. If you have versions 3.10.1 and 3.10.2, then there are only minor fixes.
  3. A basic programmer's editor. Programmers use very complicated text editors, but you should start with something simple that still works as a programmer's editor.
  4. A Terminal emulator. This is a text based command interface to your computer. If you've ever seen a movie with hacking and programming in it you've seen people furiously typing green text into a black screen so they can take down an entire alien race with their "unix exe 32 pipe attack". At first you won't need this but later you'll "graduate" to using the Terminal as it's incredibly powerful and not too hard to learn.

You should have most of the other things you'll need on your computer already, so let's install each of these requirements for your Operating System (OS).

Minimalist Start

The instructions in this exercise are designed to install most of the things you need for the rest of the course, but if you want to get going quickly with the least amount of work then install:

  1. Anaconda to get your python.

  2. Jupyter to write and run some code. This comes with Anaconda so you don't need to install it.

    • On Windows the best way to run Jupyter is to hit the windows key (start menu) and type jupyter-lab. This will start it in a way that makes sense.
    • On Linux it should be the same command in your Terminal.
    • On OSX you can either type that command in the Terminal or start the app like normal.

This will give you enough to get started, but eventually you'll hit exercises that need the Terminal and Python from the "command line." Come back to this exercise when reach that point in the course.

Windows

  1. Anaconda This is the easiest way to get a working Python install. When you install it make sure to add it to your PATH, even if it warns you that this will cause problems.
  2. Jupyter will be your primary programming environment for a while. You can think of Jupyter as an editor and terminal all in one program. This comes with Anaconda so you don't need to install it. There's even psychopaths who do all of their work only in Jupyter. It's a great tool for interactively working on ideas and doing data analysis.
  3. Geany is a great little text editor for programming. It supports almost everything you need, is small, runs on low power computers, and runs on nearly every OS. I highly recommend this for when you're starting out.
  4. Cmder this is a really nice Terminal program for Windows that includes almost everything you'll need for programming. If you're familiar with PowerShell or cmd.exe then you can think of Cmder as just a really nice window that runs PowerShell and gives you a lot of nice features. You'll want to install the full version of Cmder.

If you install all of those things then you should be ready to go. However, here are few alternative suggestions for certain people:

  1. Visual Studio Code is a more powerful programmers editor, but you should only use this when you're better at programming. You can think of Geany as a really nice bicycle you can learn to ride on, and Visual Studio Code as a Harley-Davidson Road Glide Special with extended forks and a side car seat.
  2. Plain old PowerShell will work reasonably well for this course. Later you'll need many of the tools that come with Cmder but at the start you can just run regular PowerShell. Be sure to not use PowerShell ISE.
  3. The official Python Installer although I do not recommend this on Windows because the person managing the installer refuses to add the install to your PATH. Not only that, but Microsoft has an installed python.exe that is in the PATH so when you type python in PowerShell this python.exe runs. This then tells you to install Python from the Microsoft Store, effectively hijacking your Python installation, and the Python Microsoft gives you is broken sometimes. Incidentally, the person managing the Python installer also works at Microsoft.

macOS

The setup for macOS is almost the same as Windows, except you don't need a separate Terminal program as macOS already has one:

  1. Anaconda This is the easiest way to get a working Python install. When you install it make sure to add it to your PATH, even if it warns you that this will cause problems.
  2. Geany is a great little text editor for programming. It supports almost everything you need, is small, runs on low power computers, and runs on nearly every OS. I highly recommend this for when you're starting out.
  3. Terminal is already installed on your Mac, but you will want to add it to your Dock. Hit ctrl-space and type "terminal" to start it. Once it's running, right click on the icon in your Dock and select the option to keep it in your Dock.
  4. Jupyter will be your primary programming environment for a while. This comes with Anaconda so you don't need to install it. You can think of Jupyter as an editor and terminal all in one program. There's even psychopaths who do all of their work only in Jupyter. It's a great tool for interactively working on ideas and doing data analysis.

These are nice to have software for more advanced people:

  1. Visual Studio Code as I mentioned in the Windows instructions, Visual Studio Code (VSC) is powerful, but you really do not need it early on.
  2. iTerm2 is a really nice Terminal program for macOS.
  3. The official Python Installer but I really recommend Anaconda instead as it'll work better with your macOS computer.

Linux

If you are a beginner DO NOT INSTALL LINUX. I do not care what any other programmer tells you, Linux is incredibly difficult to use if you are not a major expert at computers. I've been using Linux since the day it came out, originally installing it on a 80386 Compaq computer using a giant box of 70 3.5" floppy disks shipped to me from Slackware, and I can't even get Linux to work right on my laptop computer. If I can't make Linux work reliably then there is no hope for you, and anyone telling you to install Linux should be completely ignored. That person is only trying to get you to install Linux to increase the membership of their "tribe" and actually doesn't care about your learning objectives.

The Linux required software is almost exactly the same, but you're Linux distro will have its own way to install and manage software.

  1. Anaconda This is the easiest way to get a working Python install. When you install it make sure to add it to your PATH, even if it warns you that this will cause problems.
  2. Jupyter will be your primary programming environment for a while. You can think of Jupyter as an editor and terminal all in one program. There's even psychopaths who do all of their work only in Jupyter. It's a great tool for interactively working on ideas and doing data analysis. Jupyter comes with Anaconda so you don't need to install Jupyter separately.
  3. Geany is a great little text editor for programming. It supports almost everything you need, is small, runs on low power computers, and runs on nearly every OS. I highly recommend this for when you're starting out.
  4. Whatever terminal program your version of Linux already has will be fine.

As with the Windows and macOS there's a few optional things you could install:

  1. Visual Studio Code you're a Linux user now so this editor isn't for you. It's by Micro$oft and no real Linux user would dare touch anything by the authors of the Halloween Memo. If you're smart enough to not care then VSC is a good professional development environment, but stick to Geany until you're more capable.
  2. Vim I don't normally recommend Vim to beginners, as it's a powerful but difficult editor to learn, but you're a Linux user now. That means you love yak shaving and obsessing over tools so go for it.
  3. Emacs is an even hairier yak you can shave. Get out those clippers because you'll spend the next 10 years tweaking your Emacs Lisp configurations instead of learning to code.

All jokes aside, just stick to Geany unless you are already good with an editor you like. If you're a beginner hell bent on running Linux then good luck. I'm sure it won't get in the way of you learning to code. Nope, it's totally easy to learn 5-10 things at once.

Testing Your Setup

NOTE Before we continue, I'm going to use the word Terminal whenever I mean "start PowerShell" if you're on Windows,

or "start Terminal" when you're on macOS/OSX. Just remember, every time I say "start your Terminal" it's just a placeholder for PowerShell on Windows or Terminal on OSX.

Once you have everything installed go through these steps to confirm that everything is working:

  1. Start your Terminal (PowerShell on Windows, Terminal on OSX, etc.) and type this command exactly, spaces and all: mkdir lpthw.
  2. Once that works you have a directory lpthw that you can place your work.
  3. Go into that directory with the command cd lpthw. This command "moves" your terminal into that directory so your work is saved there.
  4. A "directory" is also called a "folder" on Windows and macOS. You can make the connection between the "directory" in your terminal and the "folder" you normally see by typing start . on Windows or open . on macOS. This opens the current directory into a graphical folder window you're used to normally seeing. If you're ever lost, type that.
  5. The start command (open on macOS) works like double-clicking that thing with your mouse. If you are in the terminal and want to "open" something, just use this command. Let's say there's a text file named test.txt and you want to open it in your editor. Type start test.txt on Windows or open test.txt on macOS.
  6. Now that you can open your Terminal and open things while in your Terminal, you'll want to start your editor. This is Geany if you've been following instructions. Start it and create a file named test.txt and save it in the lpthw directory you made. If you can't find it remember you can open it from the Terminal with start (open on macOS) and then use that folder window to find it.
  7. Once you've saved the file in the lpthw directory you should be able to type ls test.txt in your Terminal to see that it's there. If you get an error then either you're not in the lpthw directory and need to type cd ~/lpthw or you saved it in the wrong place. Try again until you can do this.
  8. Finally, in the Terminal type jupyter-lab to start up Jupyter and make sure it works. It should open your web browser and then you'll see the Jupyter app inside your browser. It's kind of like a little website on your personal computer.

Think of these tasks as a kind of puzzle to solve. If you get stuck you should watch the video for your Operating System (OS) where I show you how to do everything. I think the best way to learn this is to first attempt it yourself, then when you get stuck watch the video to see how I did it.

Learning the Command Line

You don't need to do this right now, but if you're struggling with the tasks above you might need to go through Exercise 38 if you use Windows, or Exercise 39 if you use macOS or Linux to learn the basics of the Terminal (also called the Command Line). You won't need these skills for a while but the command line is a very good introduction to controlling your computer with words. It will also help you with many other tasks in programming later, so learning it now can only help.

Next Steps

Once you have everything working you can continue with the rest of the course. If you ever run into trouble you can email me at help@learncodethehardway.com and I'll help you. When you email me for help take the time to describe your problem in as much detail as possible, and include screenshots.

Previous Lesson Next Lesson

Register for Free Support Course

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.