To install, just click the link above, then click on the version you want.
If you want to upgrade to the latest 2.7.x version or upgrade to Python 3, you can get a binary directly from the Python website. This will show you a list of Python-related packages that can be installed. To see all the versions available, search Homebrew with this: $ brew search python If you'd rather have Python 3, just replace python with python3.
To install Python 2.7.x, just type: $ brew install python You can install a few different versions of Python, including 2.7.x and 3.5.x. Now that you know what Homebrew is and have it installed, we can get on to installing Python. To install Homebrew, just follow the instructions on their website (which I linked to at the beginning of this section). For example, here are just a few things I've installed with it: android-sdk, go, mongodb, sqlite, git, imagemagick, lua, python3. It makes it much easier to install all the various tools you might need. Homebrew lets you install, update, and uninstall packages from the command line, just like apt-get does for Ubuntu. According to their website, Homebrew is "the missing package manager for OS X". Install Python with Homebrewįirst of all, if you don't know what Homebrew is and you use Mac OSX, you should.
Now, keep in mind that Mac OSX (10.8) already comes with Python 2.7 pre-installed, so these instructions will only really be helpful if you need to upgrade versions or need a better way to manage installations (like with Homebrew). Instructions for installing Python 2 and 3 are different in most cases (but not by much), so make sure you're paying attention to which version you need installed. These are the most commons you'll encounter, and each method has its own purpose, all of which I'll detail in the sections below. I figured it would be helpful to detail a few of the easiest ways to install Python, including the following:
To change directory use the command ‘cd’ like this ‘cd /home/user/pythonprojects’ or ‘cd C:\Projects\’. If you use Windows the directory is shown in the command line title bra.
On Mac OS and Linux you can see the current directory with the command pwd. That means, the directory where your python program is located. To start the program, we have to open the command line and type:įor this to work you need to be in the correct directory. You can hit command+space and type terminal, then hit enter. On Mac OS use finder to start a terminal. To open a terminal on Windows: press the windows key + r key (run program), type cmd or command and press enter. This works on all platforms (Mac OS, Windows, Linux). You can start a Python program with the terminal or command line. Related course: Complete Python Programming Course & Exercises Run Python Run from terminal I recommend using a text editor that supports syntax highlighting (text colouring) and line numbers. You can use any text editor to create a Python program. The text below can be copied into a text editor and save as hello.py. The 3rd line outputs a line of text “hello wlrd” to the screen. The first line indicates that we want to use the Python interpreter. Whenever you make a Python script, save it as name.pyĪ simple program (hello.py) is shown below. Execute Python scripts in the terminal or an IDE.