Installing/Updating Python
Once upon a time there was Python 2, and everyone was happy. Except… not really, because Python did a lot of things poorly, especially when you stopped working with the English alphabet (a.k.a. the Latin alphabet). Àçčêñtś were a disaster, and forget about using 中文 or 한글 without running into a hundred problems. Data is international, and that’s why we’re using Python 3.
A lot of people still use Python 2, though, and you’ll probably hear their cries every now and again; they can be a little vocal about their decision to not upgrade. Python 2 definitely used to make sense when a lot of software hadn’t been upgraded to use Python 3, but now any package you’ll ever want to use will be 100% Python 3 compatible.
So when you see people yelling about Python 2 vs Python 3, just ignore them and feel secure in knowing you’re on the right team.
And come on, are you still using Windows XP?
Step 0: Uninstalling things
If you have certain unfriendly versions of Python already installed on your system (especially in certain places), it can wind up causing problems. Let’s clean house before we invite guests over.
Uninstalling Anaconda
If you installed it at some point, make sure you’ve uninstalled Anaconda. You can find instructions over here.
Never heard of Anaconda? You’re fine!
Uninstalling any other Pythons (OS X only)
Open up Finder, press Command+Shift+G
, tell it to go to /Library/Frameworks
. There might be a folder called Python.framework
in there - if there is, delete it! We’ll replace this Python with good cool normal fun Pythons
If the folder doesn’t exist, don’t worry, just go to the next step.
Note: If you already used
brew install
to install Python, acheckbrew doctor
and do whatever it tells you to do regarding Python.
Step 1: Installing Python 3
Installing Python on Windows
Follow the directions on the Python site.
Now skip to Step 3.
Installing Python on OS X
OS X: Python prerequisites
Note: If/when you get a prompt that says “Password: []” and you type and type and nothing shows up just type the password and hit enter, it doesn’t look like it’s doing anything but it is! It’s just maintaining your privacy by not displaying it.
You might need to install the XCode Command Line Tools. Try the following line in a new Terminal window.
xcode-select --install
Homebrew is a package manager for OS X - it helps us install pieces of software more easily than downloading them individually. We’re going to install Homebrew and then use it to install Python 3. First, install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then paste the following to give Homebrew a little setup magic:
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
OS X: Python installation
Now you can use the brew
command to install Python 3.
brew install python3
Do you know what you just did? No? Yeah, you shouldn’t! It’s all magic at this point. Don’t worry, we’ll get there eventually.
Step 2: Installing/updating pip
(all platforms)
Next up: let’s get a little familiar with the command known as pip
.
pip
stands for “Pip Installs Packages,” because… pip
is a command to install packages. Packages are little bundles of code that help you do common tasks!
Since we’re using Python 3, we’ll be using the pip3
command for the moment. Try this command out (no big deal if it doesn’t work):
pip3 install -U pip
Did it yell something about “permissions error” or anything? If it did try this one instead (again, no big deal if it doesn’t work):
sudo pip3 install -U pip
Next step: Installing virtualenv
Now that you’re done installing Python, you need to install its friend virtualenv
- directions are here.