Skip to content

Instantly share code, notes, and snippets.

@sajadbahar
Forked from floer32/centos_python_env_setup
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save sajadbahar/9240217 to your computer and use it in GitHub Desktop.

Select an option

Save sajadbahar/9240217 to your computer and use it in GitHub Desktop.
CentOS 6: Install Python 2.7.6, setuptools, pip and virtualenv all you need for your new CentOS server. Run script with `sudo`.
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# 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.6
wget --no-check-certificate http://www.python.org/ftp/python/2.7.6/Python-2.7.6rc1.tar.bz2
tar xf Python-2.7.6rc1.tar.bz2
cd Python-2.7.6rc1
./configure --prefix=/usr/local
make && make altinstall
# get the setup script for Setuptools:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# Then install it for Python 2.7:
python2.7 ez_setup.py
# Now install pip using the installed setuptools:
easy_install-2.7 pip
# Install virtualenv for Python 2.7:
pip2.7 install virtualenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment