Last active
August 29, 2015 14:19
-
-
Save starding/af4ee82dde11a685c4d7 to your computer and use it in GitHub Desktop.
install Python 2.7 and Python 3.3 on CentOS 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum groupinstall "Development tools" | |
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel | |
# Python 2.7.6: | |
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz | |
tar xf Python-2.7.6.tar.xz | |
cd Python-2.7.6 | |
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
make && make altinstall | |
# Python 3.3.5: | |
wget http://python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz | |
tar xf Python-3.3.5.tar.xz | |
cd Python-3.3.5 | |
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
make && make altinstall | |
# First get the setup script for Setuptools: | |
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | |
# Then install it for Python 2.7 and/or Python 3.3: | |
python2.7 ez_setup.py | |
python3.3 ez_setup.py | |
# Now install pip using the newly installed setuptools: | |
easy_install-2.7 pip | |
easy_install-3.3 pip | |
# With pip installed you can now do things like this: | |
pip2.7 install [packagename] | |
pip2.7 install --upgrade [packagename] | |
pip2.7 uninstall [packagename] | |
# Install virtualenv for Python 2.7 and create a sandbox called my27project: | |
pip2.7 install virtualenv | |
virtualenv-2.7 my27project | |
# Use the built-in pyvenv program in Python 3.3 to create a sandbox called my33project: | |
pyvenv-3.3 my33project | |
# Check the system Python interpreter version: | |
python --version | |
# This will show Python 2.6.6 | |
# Activate the my27project sandbox and check the version of the default Python interpreter in it: | |
source my27project/bin/activate | |
python --version | |
# This will show Python 2.7.6 | |
deactivate | |
# Activate the my33project sandbox and check the version of the default Python interpreter in it: | |
source my33project/bin/activate | |
python --version | |
# This will show Python 3.3.5 | |
deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment