Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn Python in 7 Days

You're reading from   Learn Python in 7 Days Begin your journey with Python

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781787288386
Length 280 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Mohit Raj Mohit Raj
Author Profile Icon Mohit Raj
Mohit Raj
Bhaskar N. Das Bhaskar N. Das
Author Profile Icon Bhaskar N. Das
Bhaskar N. Das
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Python FREE CHAPTER 2. Type Variables and Operators 3. Strings 4. Lists 5. Dictionary 6. Control Statements and Loops 7. Function and Scope of Variable 8. Modules and Packages 9. File Handling and Exceptions 10. Collections 11. Class and Objects

Installation

Here we will look forward to the installation of Python on three different OS platforms, namely, Windows, Linux, and Mac OS. Let's begin with the Windows platform.

Installation on Windows platform

Python 2.x can be downloaded from https://www.python.org/downloads. The installer is simple and easy to install. Perform the following steps to install the setup:

  1. Once you click on setup installer, you will get a small window on your desktop screen as shown here; click on Next:
  1. Provide a suitable installation folder to install Python. If you don't provide the installation folder, then the installer will automatically create an installation folder for you, as shown in the following screenshot. Click on Next:
  1. After completion of step 2, you will get a window to customize Python as shown in the preceding screenshot. Notice that the Add python.exe to Path option has been marked x. Select this option to add it to system path variable (which will be explained later in the chapter), and click on Next:
  1. Finally, click on Finish to complete the installation:

Installation on Linux platform

These days most of the Linux-based systems come preloaded with Python, so in most cases, you do not need to install it separately. However, if you do not find your desired version of Python on the Linux platform, you can download your desired version for a particular Linux platform from the site https://www.python.org/downloads/source/. Perform the following steps:

  1. Extract the compressed file using the tar -xvzf python_versionx.x command.
  2. Browse the directory of the compressed file as shown in the screenshot:
  1. Run the following commands:
      [root@localhost Python-2.7.12]# ./configure
[root@localhost Python-2.7.12]# make
[root@localhost Python-2.7.12]# make install
  1. Use the command as shown in screenshot to ensure that Python is running:

Installation on Mac OS

For Mac OS, you will get the installer from the site https://www.python.org/downloads/mac-osx/. 

For the new Mac OS X, Sierra comes loaded with Python 2.7 and it's good for learning but the same cannot be used to develop advanced-level programs. You do not need to separately install Python on the new Mac OS X. However, a word of caution is that the version of Python packed with the Mac OS could be out of date and might require updating. If you still want to install a separate version, you can follow the simple steps mentioned as follows:

  1. First of all, you might require to install Xcode, Xcode is the IDE for  platform and can be downloaded from the Apple appstore.
  2. Once Xcode is installed, you need to install the command-line tools, which can be installed by running the xcode-select --install command on the terminal found under /Applications/Utilities/, as shown in the following screenshot:
  1.  A pop-up window appears with three different options as shown here:
  1. Once you click on Install and agree to their terms and conditions, the command-line tools will start to download and will be installed in few minutes depending on the Internet connection.
  1. The next step in the process would be to install Homebrew, which is a package manager for Mac OS and handles the Python package. In order to install Homebrew, simply provide the following inputs to the terminal:

      /usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. To install the latest python2 version, simply type brew install python on the terminal:
      $ brew install python
In order to install python3, you need to use brew install python3.
You have been reading a chapter from
Learn Python in 7 Days
Published in: May 2017
Publisher: Packt
ISBN-13: 9781787288386
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime