Skip to content

Instantly share code, notes, and snippets.

@daspecster
Last active March 22, 2016 06:27
Show Gist options
  • Save daspecster/d7f71fcb0553af730490 to your computer and use it in GitHub Desktop.
Save daspecster/d7f71fcb0553af730490 to your computer and use it in GitHub Desktop.
Update EC2 Python virtualenv
# Thanks to Sebastian Kreutzberger
# Source: http://www.lecloud.net/post/61401763496/install-update-to-python-2-7-and-latest-pip-on-ec2
# install build tools
sudo yum install make automake gcc gcc-c++ kernel-devel git-core -y
# install python 2.7 and change default python symlink
sudo yum install python27-devel -y
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
# yum still needs 2.6, so write it in and backup script
sudo cp /usr/bin/yum /usr/bin/_yum_before_27
sed -i 's/python$/python2.6/g' /usr/bin/yum
sed -i 's/python2\.6[\.|0-9].*/python2.6/g' /usr/bin/yum
sed -i 's/python2\.[0-5|7-9].*/python2.6/g' /usr/bin/yum
# should display now 2.7.5 or later:
python -V
# now install pip for 2.7
sudo curl -o /tmp/ez_setup.py https://bootstrap.pypa.io/ez_setup.py
sudo /usr/bin/python27 /tmp/ez_setup.py
sudo /usr/bin/easy_install-2.7 pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
# should display current versions:
pip -V && virtualenv --version
@jg75
Copy link

jg75 commented Dec 10, 2014

I would suggest changing

sudo sed -i s/python/python2.6/g /usr/bin/yum 
sudo sed -i s/python2.6/python2.6/g /usr/bin/yum 

To

sed -i 's/python$/python2.6/g' /usr/bin/yum
sed -i 's/python2\.6[\.|0-9].*/python2.6/g' /usr/bin/yum
sed -i 's/python2\.[0-5|7-9].*/python2.6/g' /usr/bin/yum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment