📕
SEIRFX
  • Introduction
  • About These Notes
  • Schedule
  • Unit 2
    • Node
      • Internet Fundamentals
      • Full-Stack Fundamentals
      • Intro to Node
      • Node Modules
      • Node Packages
    • Express
      • Intro to Express
      • Routes
      • Routes Lab
      • Views
      • Templates
      • Layouts & Controllers
    • CRUD & REST
      • GET & POST
      • GET & POST Lab
      • PUT & DELETE
    • API Calls in Express
      • Axios
      • Request (no longer maintained)
    • Sequelize
      • Terminology
      • Setup
      • Using Models
      • Seeding Data
      • Validations and Migrations
      • Resources
      • 1:M Relationships
      • N:M Relationships
    • Express Authentication
      • Research Components
      • Code Components
      • Auth in Theory
        • Sessions
        • Passwords
        • Middleware
        • Hooks
      • Auth in Practice
        • Create the User
        • User Signup
        • Sessions
        • User Login
        • Authorization and Flash messages
  • Development Workflow
    • Command Line
      • The Terminal
      • Filesystem Navigation
      • File Manipulation
      • Additional Topics
    • Intro to Git
      • Version Control
      • Local Git
      • Remote Git
      • Git Recipes
    • Group Collaboration
      • Git Workflows
      • Project Roles and Tools
    • VS Code Tips & Tricks
  • HTML/CSS
    • HTML
    • CSS Selectors
    • CSS Box Model and Positioning
      • Box Model
      • Display and Positioning
      • Flexbox
      • Grid
      • Flexbox & Grid Games
      • Floats and Clears
      • Additional Topics
    • Advanced CSS
      • Responsive Design
      • Pseudo-Classes/Elements
      • Vendor Prefixes
      • Custom Properties
      • Additional Topics
    • Bootstrap
    • CSS Frameworks
    • Accessibility
  • JavaScript
    • Primitives
    • Arrays
    • Objects
      • Objects Lesson
      • Objects quick guide
      • Object-ception
    • Control Flow
      • Boolean Expressions
      • Conditionals
      • Loops
      • Promises
    • Functions
      • Scope
      • Callbacks
      • Higher Order Functions
      • Callbacks Review Lab
      • Timing Functions
      • Iterators
      • Combining Data Types
      • Combining Data Types Lab
    • Javascript in the browser
      • DOM and Events
      • DOM Manipulation
      • DOM Review
      • DOM Review Lab
      • HP DOM Lab
      • Programmatic DOM Manipulation
      • Grids & Pyramids
      • DOM & Data
      • DOM Events
      • Color Palette Picker
      • Sketchpad
    • HTML5 Canvas
    • How To Reduce Redundancy
    • OOP
      • Westworld Lab
      • OOP Factories
      • OOP Inheritance
      • OOP Inheritance Lab
      • Tomagotchi Lab
      • OOP Space Battle
      • OOP Snowman
      • (2019) JavaScript OOP
      • (2016) OOP with Classes
      • (1995) OOP with Prototypes
      • Constructors
      • Prototypes
    • Intro to TDD
    • Scoping
    • Inheritance
      • Prototypal Inheritance
      • Call, Apply, and other Functions
      • ES6 Inheritance
      • Resources
    • Custom Node Modules
    • Additional Topics
      • AJAX, Fetch, and Async/Await
      • AJAX w/JSON and Localstorage
        • AJAX w/JSON
        • Local Storage
      • Async module
      • Data Scraping
  • jQuery
    • Intro
      • DOM Manipulation
      • Reddit Practice
      • Styling
      • Events
    • Plugins
    • AJAX
  • APIs
    • Fetch
    • AJAX w/jQuery
    • AJAX w/Fetch
  • Databases
    • Intro to SQL
    • Advanced SQL
    • MongoDB
      • Intro to NoSQL
      • CRUD in MongoDB
      • Data Modeling
      • Intermediate Mongo
  • Left over Node/Express
    • Testing with Mocha and Chai
    • Mongoose
      • Mongoose Associations
    • JSON Web Tokens
      • Codealong
    • Additional Topics
      • oAuth
      • Geocoding with Mapbox
      • Geocoding and Google Maps
      • Cloudinary
      • Websockets with Socket.io
      • SASS
  • Ruby
    • Intro to Ruby
    • Ruby Exercises
    • Ruby Classes
    • Ruby Testing with Rspec
    • Ruby Inheritance
    • Ruby Data Scraping
  • Ruby on Rails
    • Intro to Rails
    • APIs with Rails
    • Asset Pipeline
    • Rails Auth and 1-M
      • Auth Components
    • Rails N:M
    • ActiveRecord Polymorphism
    • Additional Topics
      • oAuth
      • SASS
      • Rails Mailers
      • Cloudinary
      • Jekyll
  • React (Updated 2019)
    • ES6+/ESNext
      • Const and Let
      • Arrow Functions
      • Object Literals and String Interpolation
      • ES6 Recap
      • ES6 Activity
    • Intro to React
      • Create React App
      • Components and JSX
      • Virtual DOM
      • Props
      • Dino Blog Activity
      • Nested Components
      • Lab: LotR
    • React State
      • Code-Along: Edit Dino Blog
      • Lab: Simple Calc
      • Lifting State
    • React Router
      • Browser History/SPAs
      • React Router (lesson and full codealong)
      • Router Lab
    • Fetch and APIs
      • APIs with Fetch and Axios
      • Fetch the Weather
    • React Hooks
    • React LifeCycle
      • Lab: Component LifeCycle
    • React Deployment
    • Additional Topics
      • React Frameworks
        • Material UI Theming
      • Typescript
        • More Types and Syntax
        • Tsconfig and Declaration Files
        • Generics with Linked List
      • Redux
      • TypeScript
      • Context API
      • React Native
  • Meteor
  • Deployment and Config
    • Installfest
      • Mac OSX
      • Linux
      • Git Configuration
      • Sublime Packages
    • Deploy - Github Pages
    • Deploy - Node/Sequelize
    • Deploy - Node/MongoDB
    • Deploy React
    • Deploy - Rails
      • Foreman (Environment Variables)
    • Deploy - AWS Elastic Beanstalk
    • Deploy - S3 Static Sites
    • Deploy - Django
    • Deploy - Flask
  • Data Structures and Algorithms
    • Recursion
    • Problem Solving - Array Flatten
    • Binary Search
    • Algorithm Complexity
    • Stacks and Queues
    • Bracket Matching
    • Ruby Linked Lists
      • Sample Code
      • Beginner Exercises
      • Advanced Exercises
    • JS Linked Lists
      • Sample Code
      • Beginner Exercises
      • Beginner Solutions
    • Hash Tables
    • Intro to Sorting
    • Insertion Sort
    • Bucket Sort
    • Bubble Sort
    • Merge Sort
    • Quick Sort
    • Heap Sort
    • Sorting Wrapup
    • Hashmaps
    • Trees and Other Topics
  • Python
    • Python Installation
    • Intro to Python
    • Python Lists
    • Python Loops
    • Python Dictionaries
    • Python Sets and Tuples
    • Python Cheatsheet
    • Python Functions
    • Python Classes
    • Python Class Inheritance
    • Intro to Flask
    • Intro to SQLAlchemy
      • Flask and SQLAlchemy
    • Using PyMongo
    • Intro to Django
    • CatCollector CodeAlong
      • URLs, Views, Templates
      • Models, Migrations
      • Model Form CRUD
      • One-to-Many Relations
      • Many-to-Many Relations
      • Django Auth
    • Django Cheatsheet
    • Django Auth
    • Django Polls App Tutorial
    • Django School Tool Tutorial
    • Django 1:M Relationships
    • Custom Admin Views
    • Data Structures and Algorithms
      • Recursion
      • Binary Search
      • Stacks and Queues
      • Linked Lists
      • Binary Trees
      • Bubble Sort
      • TensorFlow & Neural Networks
    • Adjacent Topics
      • Raspberry Pi
      • Scripting
  • Assorted Topics
    • History of Computer Science
    • Regular Expressions
    • Being Successful in SEI
    • Internet Fundamentals
      • Internet Lab
    • Adjacent Workflow
      • UX/UI
      • Wireframing Exercise: Build an Idea
      • Agile
    • Post SEI
      • Learning Resources
      • Deliverables -> Portfolio
      • FAQ
  • Projects
    • Project 1
    • Project 2
    • Project 3
      • Project 3 Pitch Guidelines
    • Project 4
    • Past Projects
      • Project 1
      • Project 2
      • Project 3
      • Project 4
      • Portfolios
    • Post Project 2
    • MEAN Hackathon
      • Part 1: APIs
      • Part 2: Angular
    • Portfolio
  • Web Development Trends
  • Resources
    • APIs and Data
    • Tech Websites
    • PostgreSQL Cheat Sheet
    • Sequelize Cheat Sheet
    • Database Administration
  • Archived Section
    • (Archived) ReactJS
      • Intro to React
        • Todo List Codealong
        • Additional Topics
      • Deploy React
      • React with Gulp and Browserify
        • Setting up Gulp
        • Additional Gulp Tasks
      • React Router
        • OMDB Router
        • OMDB Search
        • Additional Resources
      • React Animations
        • CSS Animations
    • AngularJS
      • Intro to AngularJS
        • Components and SPA
        • Create an Angular App
      • Angular Directives and Filters
      • Angular Animation
      • Angular Bootstrap Directives
        • Bootstrap Modals
      • Angular $http
      • Angular Services
        • Service Recipes
        • ngResource
        • Star Wars Codealong
      • Angular Routing
      • Angular + Express
      • Angular Authentication
        • Additional Topics
      • Angular Components
      • Angular Custom Filters
      • Angular Custom Directives
Powered by GitBook
On this page
  • Install Python
  • Python 2 vs. Python 3
  • Actual Installation

Was this helpful?

  1. Python

Python Installation

PreviousPythonNextIntro to Python

Last updated 4 years ago

Was this helpful?

Install Python

Your computer probably automatically has Python on it. We're going to run some installation stuff to make sure it's got the latest and greatest that Python has to offer.

Python 2 vs. Python 3

Note: there are two versions of Python. There's Python 2 and Python 3. Python 3 was released in 2008 and included breaking changes. Breaking changes means that an upgrade changes the way some code works and old code won't always work with the way new code wants it to be written.

Why did Python 3 introduce breaking changes? Well, it turns out there were some things in Python 2 that could have been designed better. Guido, and the Python community decided that it would be worth it, in the long haul, to fix those mistakes and get the language back on track for where they want it to be in the future. Upgrading to Python 3 is a good thing!

Wait, so if upgrading to Python 3 is a good thing, why are some people still using Python 2?

It turns out that converting some code from Python 2 to Python 3 is hard and requires lots of work. It's easy to convert small projects from Python 2 to Python 3, but it's hard to convert large, complex projects. In an ideal world everyone would be able to convert their projects and Python 2 would be laid down to rest. In reality, lots of large, popular projects started being written in Python 2 and they just don't have the resources (or incentives) to upgrade to Python 3.

To us, the differences between Python 2 and Python 3 are minimal. They're very much still the same language. Anyone that knows either Python 2 or Python 3 is able to switch to using the other easily.

Perhaps the most notable difference is how you print things.

# python 2 doesn't use parenthesis in print statements
print "hello world!"

# python 3 makes print use parenthesis, just like every other function.
# this is a great change!
print("hello world!")

See? Switching between the two isn't that big of a deal. For what we do. If you're curious, take a look at this long list of actual differences between Python 2 and Python 3:

It's good that Python made the breaking changes. In this class we're going to use Python 3, always. This requires us to be extra sure that we never "accidentally" use Python 2. Be aware!

Actual Installation

Here's the tools we're snaggin:

  • Python 3 - the latest and greatest version of Python

  • IPython - an enhanced Python shell that provides excellent features

    beyond the normal Python shell. For example:

    • syntax highlighting

    • auto-completion

    • when you press the up arrow it lets you edit entire functions and blocks

      of code.

  • Flask - a minimalist Python web microframework, much like Express

  • Django - a larger Python web framework

Use brew to install Python 3!

brew install python3

Use pip, a Python package installer. pip stands for "Pip Installs Packages." Programmers love recursive acronyms.

Notice, there's two versions of pip. One installs things for Python 2 another installs things for Python 3. Use pip3 to be explicit. If you're lucky, maybe your system uses pip for Python 3 by default. Let's assume we're not lucky and always use pip3, to be explicit.

You can verify what version of Python pip and pip3 use:

pip --version
pip3 --version

Should show these, respectively:

pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Ok. let's install stuff:

pip3 install ipython
pip3 install Flask
pip3 install Django

Notice that python refers to the default system installation of Python 2, and python3 refers to the latest and greatest install of Python 3.

Always use python3. Always.

python  --version         2.7.10
python3 --version         3.6.0
ipython3 --version        5.1.0
django-admin.py version   # 1.10.5

Start ipython and verify it uses Python 3 by default. (Notice that ipython and ipython3 are both legitimate commands. If ipython looks like it's using Python 2 then run ipython3 to be explicit.

We're looking for something like imPython 3.6.0 at the beginning of the first line here when IPython starts up:

imPython 3.6.0 (default, Dec 24 2016, 08:01:42)
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

Make sure that you're version numbers are in the ballpark of what you see above.

Great. Python3 and the enhanced IPython shell are all installed. Let's hop into the IPython shell and check to see if Flask and Django were installed properly.

Now run ipython3 in your Terminal to activate the enhanced IPython shell. We're going to make sure Flask and Django are available for us to import within Python.

import flask
import django

print("Flask version:", flask.__version__)
print("Django version:", django.__version__)
Flask version: 0.12
Django version: 1.10.5

Also, while youre in the IPython shell, let's go ahead and check out one of it's awesome features: auto-completion!

The IPython shell doesn't leave you hanging when you don't remember something. You can press TAB while you're in the middle of something and it detects what variables, data types, and functions you have available and it offers suggestions.

Let's make a variable equal to a string, then type s. and press the TAB key to see what IPython suggests. We'll see that it creates a pop-up menu that shows all the methods available to us for strings.

It all looks something like below. How cool is that? Here we are knowing nothing about Python and our shell helps us out by showing what sort of things we can do. Use the up and down arrow keys to flip through this list and pick a function. I chose upper.

Also, it came back and showed me <function str.upp> so I added parenthesis so the function was actually called.

In [5]: s = "python is awesome"

In [6]: s.
         s.capitalize   s.isalnum      s.join         s.rsplit
         s.casefold     s.isalpha      s.ljust        s.rstrip
         s.center       s.isdecimal    s.lower        s.split
         s.count        s.isdigit      s.lstrip       s.splitlines
         s.encode       s.isidentifier s.maketrans    s.startswith
         s.endswith     s.islower      s.partition    s.strip
         s.expandtabs   s.isnumeric    s.replace      s.swapcase
         s.find         s.isprintable  s.rfind        s.title
         s.format       s.isspace      s.rindex       s.translate
         s.format_map   s.istitle      s.rjust        s.upper
         s.index        s.isupper      s.rpartition   s.zfill
In [7]: s.upper
Out[7]: <function str.upper>

In [8]: s.upper()
Out[8]: 'PYTHON IS AWESOME'

OK! Those are our tools. Now you're ready to get a proper crash-course introduction to Python.

http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html