Installation Guide
Welcome to the first Python tutorial. We’re going to look at getting Python up and running on your computer, then look at a few simple operations to get to grips with the development environment and syntax.
Installation
Mac
Mac OSX ships with Python 2.7 which, while still a great language, is very outdated these days, so we need to upgrade:
- Make sure you’re running an updated version of OSX. You should at least have OS 10.3, and most modern Macs are running much later than that anyway, but it’s worth noting this requirement here.
- Head to the Python website.
- Click “Downloads”.
- There will be two options; one for Python 3 and one for Python 2. Download Python 3. At the time of writing, the version available is 3.8.3.
- When the download’s complete, your browser should automatically mount the
disk image and open a Finder window of what’s inside, but if that doesn’t
happen, you’ll have to find the file
Python.mpkg
in your downloads folder and double-click it to get started. - Once the installer is running hit
Continue
a number of times and agree to the Free software license as well as enter your administrator password. Just follow the prompts and you’ll be fine.
If you get lost, have a look at this tutorial with pictures on DiveIntoPython3.
Windows:
- Head to the Python website.
- Click “Downloads”.
- There will be two options; one for Python 3 and one for Python 2. Download Python 3. At the time of writing, the version available is 3.8.3.
- Run the downloaded installer and click Next until you reach the Customization page.
- Scroll down to the bottom and choose to Add python.exe to PATH.
- Continue clicking Next until it’s installed.
If you get lost, have a look at this tutorial with pictures on DiveIntoPython3.
Linux
All modern Linux distributions should support installing Python 3 via the package manager. However, each distribution likes to do things slightly differently, so these instructions may need to be modified for your situation.
Debian/Ubuntu
Python 3 is available via apt, so you can install it with apt install
python3
.
Redhat/CentOS
Python 3 isn’t yet available in default Redhat/Centos installations, so you
have to use the scl
workaround:
- Install scl-utils:
yum install scl-utils
- Install the extra repo needed for Pytyhon 3:
rpm -Uvh https://www.softwarecollections.org/en/scls/rhscl/python33/epel-7-x86_64/download/rhscl-python33-epel-7-x86_64.noarch.rpm
- Install Python 3 with this new repo:
yum install Python33
(no the second3
is not a typo) - Run
scn enable python3 /bin/bash
. This will put you into a shell that supports Python 3.
For more information on this process, take a look at this tutorial.
Arch
Python 3 is available via Pacman, so all you need to do is pacman -S python
.
Gentoo
You’ve already got it :-)
Opening the REPL
Python is often developed with the aid of a REPL, or Read-Eval-Print-Loop. The REPL is a way of getting immediate feedback as you work. Python’s REPL is called IDLE.
It’s very important to find what Python version you are working with.
On Windows, open cmd
or on Mac OS / GNU/Linux open terminal
and type
(without the $
sign):
$ python --version
What you should see is:
$ python 3.8.3
On Mac OS running python --version
might run the outdated Python 2.7 which is bundled with the operating system.
If this is your case, then you need to run python3
instead of python
.
Any 3.* version should do for this tutorial to work.
Now, open the REPL by typing:
$ python
And you should see something like this:
Python 3.8.3 (default, Aug 6 2016, 15:44:26)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Now you’re all set!