Python on EC2

Running Python on EC2 is a pain, and installing packages can be more of a pain (version clashes, permissions etc). Turns out the easiest way was just to use virtualenv. Here’s a helper script I created:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sudo yum -y install gcc-c++ python27-devel atlas-sse3-devel lapack-devel
curl -O from https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
pip install virtualenv
cd ~/
mkdir ./.virtualenv
cd ./.virtualenv
virtualenv default
source ~/.virtualenv/default/bin/activate
echo "source ~/.virtualenv/default/bin/activate" >> ~/.bashrc
source ~/.bashrc
pip install --upgrade pip
pip install numpy
pip install scipy
# pip install gensim

This would get your virtualenv setup, and the default environment would be used every time you log in. It also upgrades pip, installs numpy and scipy as a demonstration.