Skip to content

Instantly share code, notes, and snippets.

@brogand93
Forked from floer32/centos_python_env_setup
Last active August 29, 2015 13:56
Show Gist options
  • Save brogand93/8828774 to your computer and use it in GitHub Desktop.
Save brogand93/8828774 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
yum -y install bzip2-devel openssl-devel ncurses-devel # gen'l reqs
yum -y install mysql-devel # req'd to use MySQL with python ('mysql-python' package)
yum -y install libxml2-devel libxslt-devel # req'd by python package 'lxml'
yum -y install unixODBC-devel # req'd by python package 'pyodbc'
yum -y install sqlite sqlite-devel # you will be sad if you don't install this before compiling python, and later need it.
# Alias shasum to == sha1sum (will prevent some people's scripts from breaking)
echo 'alias shasum="sha1sum"' >> $HOME/.bashrc
# Install Python 2.7.4 (do NOT remove 2.6, by the way)
wget --no-check-certificate http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tar.bz2
tar xf Python-2.7.4.tar.bz2
cd Python-2.7.4
./configure --prefix=/usr/local
make && make altinstall
# Install virtualenv and virtualenvwrapper
wget --no-check-certificate https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.9.1.tar.gz#md5=07e09df0adfca0b2d487e39a4bf2270a
tar -xvzf virtualenv-1.9.1.tar.gz
python virtualenv-1.9.1/setup.py install
wget --no-check-certificate https://pypi.python.org/packages/source/v/virtualenvwrapper/virtualenvwrapper-4.0.tar.gz#md5=78df3b40735e959479d9de34e4b8ba15
tar -xvzf virtualenvwrapper-*
python virtualenvwrapper-4.0/setup.py install
echo 'export WORKON_HOME=~/Envs' >> .bashrc # Change this directory if you don't like it
source $HOME/.bashrc
mkdir -p $WORKON_HOME
echo '. /usr/bin/virtualenvwrapper.sh' >> .bashrc
source $HOME/.bashrc
# Done!
# Now you can do: `mkvirtualenv foo --python=python2.7`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment