Contents
In 2020, we’re working on improvements to the heart of pip. Please learn more and take our survey to help us do it right. If you find bugs, need help, or want to talk to. Use PiP to show the picture from any webcam on your screen, nicely integrated as 'Picture in Picture'. Define a keyboard shortcut to smoothly fade in and out the video during a live presentation.
Lesson Goals
This lesson shows you how to download and install Python modules. Thereare many ways to install external modules, but for the purposes of thislesson, we’re going to use a program called pip, easily installable on mac/linux and windows. As of Python 2.7.9 and newer, pip is installed by default. This tutorial will be helpful for anyone using older versions of Python (which are still quite common).
Introducing Modules
One of the great things about using Python is the number of fantasticcode libraries that are widely and easily available that can save you alot of coding, or simply make a particular task (like creating a CSVfile, or scraping a webpage) much easier. When Googling for solutions toproblems, you’ll often find sample code that uses code libraries youhaven’t heard about before. Don’t let these scare you away! Once theselibraries are installed on your computer, you can use them by importingthem at the beginning of your code; you can import as many libraries asyou’d like, such as
For new Python users, it can be a bit intimidating to download andinstall external modules for the first time. There are many ways ofdoing it (thus adding to the confusion); this lesson introduces one ofthe easiest and most common ways of installing python modules.
The goal here is to install software on your computer that canautomatically download and install Python modules for us. We’re going touse a program called pip.
Note: As of Python 3.4, pip will be included in the regular install.There are many reasons why you might not have this version yet, and incase you don’t, these instructions should help.
Mac and Linux instructions
As per the pip documentation, we can download a python script to installpip for us. Using a Mac or Linux, we can install pip via the commandline by using the curl command, which downloads the pip installationperl script.
once you’ve downloaded the get-pip.py file, you need to execute it withthe python interpreter. However, if you try to execute the script withpython like
the script will most likely fail because it won’t have permissions toupdate certain directories on your filesystem that are by default set sothat random scripts cannot change important files and give you viruses.In this case—and in all cases where you need to allow a script that youtrust to write to your system folders—you can use the sudo command(short for “Super User DO”) in front of the python command, like
Mac Upgrade Pip
Windows Instructions
As with the above platforms, the easiest way to install pip is throughthe use of a python program called get-pip.py, which you can downloadhere. When you open this link, you might be scared of the massivejumble of code that awaits you. Please don’t be. Simply use your browserto save this page under its default name, which is get-pip.py. It mightbe a good idea to save this file in your python directory, so you knowwhere to find it.
Once you have saved this file, you need to run it, which can be done intwo ways. If you prefer using your python interpreter, just right-clickon the file get-pip.py and choose “open with” and then choose whateverpython interpreter you care to use.
![For For](/uploads/1/1/8/8/118881250/121602131.jpg)
If you prefer to install pip using the windows command line, navigate towhatever directory you’ve placed python and get-pip.py. For thisexample, we’ll assume this directory is python27, so we’ll use thecommand C:>cd python27. Once you are in this directory, run thecommand
Download Pip Mac Terminal
If you want more information or help with a weird error message, check out the StackOverflowpage that seems to be regularly updated.
![Mac upgrade pip Mac upgrade pip](/uploads/1/1/8/8/118881250/147716367.png)
Installing Python Modules
Install Pip Mac
Now that you have pip, it is easy to install python modules since itdoes all the work for you. When you find a module that you want to use,usually the documentation or installation instructions will include thenecessary pip command, such as
Install Pip In Mac Os
Remember, for the same reasons explained above (on Mac or Linux systems, but not Windows), you might need to run pip with sudo, like
Sometimes, especially on Windows, you may find it helpful to use the -m flag (to help python find the pip module), like
Download Pip
Happy installing!