modified: 2010-11-30-the-barrymores-stole-my-heart-then-crushed-it.rst modified: 2010-12-31-four2go-a-new-spin-on-an-old-classic.rst modified: 2011-01-02-a-homegrown-python-bread-crumb-module.rst modified: 2011-01-05-how-did-stack-overflow-get-initial-traction.rst modified: 2011-01-09-graphic-design-powerhouse-wacom-bamboo-ubuntu-and-mypaint.rst modified: 2011-01-10-i-just-used-google-to-purchase-chinese-food-takeout-for-two.rst modified: 2011-01-11-response-to-l-theanine-a-4000-year-old-mind-hack.rst modified: 2011-03-26-porting-the-chaostheory-wordpress-theme-to-pylowiki.rst modified: 2011-04-03-voice-over-ip-with-teamspeak.rst modified: 2011-04-16-dropbox-encryption-with-truecrypt.rst modified: 2011-06-25-google-bot-attempts-to-crawl-shortest-urls-first.rst modified: 2011-07-02-add-a-breadcrumb-subscriber-to-a-pyramid-project-using-4-simple-steps.rst modified: 2011-07-11-a-hack-to-gain-80-percent-efficiency-when-creating-github-projects.rst modified: 2011-08-08-programming-is-like-alchemy.rst modified: 2011-08-18-security-professionals-yes-we-appear-vulnerable-but-that-attack-vector-will-never-happen.rst modified: 2011-08-22-python-image-grabber-pig-py.rst modified: 2011-09-06-deliberating-the-viewers-vs-doers-concept.rst modified: 2011-09-08-a-system-administrators-guide-to-installing-and-maintaining-multiple-python-environments.rst modified: 2011-09-09-hacker-olive-oil-lamp-crafted-from-home-materials.rst modified: 2011-10-01-how-do-i-calculate-the-m-in-my-mvp.rst modified: 2011-10-05-linkpeek-com-web-address-thumbnail-api-alpha-release.rst modified: 2011-10-12-a-better-way-to-show-website-backlinks.rst modified: 2011-10-15-i-cancelled-my-xbox-live-automatic-renewal.rst modified: 2011-10-15-r8168-driver-issues-after-ubuntu-11-10-upgrade-kernel-linux-3-0.rst modified: 2011-11-30-how-to-incorporate-custom-configuration-in-a-pyramid-application.rst modified: 2011-12-19-linkpeek-com-webpage-to-image-was-a-by-product.rst modified: 2012-01-18-today-i-lost-a-customer.rst modified: 2012-02-16-my-4-month-olds-15-minutes-of-fame.rst modified: 2012-03-03-how-to-save-hundreds-of-dollars-on-groceries-without-clipping-coupons.rst modified: 2012-03-26-nosslsearch-cname-is-a-bad-idea-and-solution.rst modified: 2012-05-19-high-load-on-web-server-after-updating-from-ubuntu-10-04-to-ubuntu-12-04-lts.rst modified: 2012-06-10-always-attempt-to-scale-vertically-first.rst modified: 2012-06-29-miniuri-parser-and-ago-human-timedelta.rst modified: 2013-01-09-ago-py-human-readable-timedelta0-0-4-release.rst modified: 2013-03-02-virt-backs-domfetcher-class-returns-doms-from-libvirt-api.rst modified: 2013-03-22-guido-name-dropped-tornado-python-tulip-and-pep-3156.rst modified: 2013-05-26-honey-i-just-deleted-linkpeek-com.rst modified: 2013-06-20-high-load-and-cpu-usage-craftbukkit-compared-to-vanilla-minecraft.rst modified: 2013-10-19-simplify-deployments-with-upstart-and-uwsgi.rst modified: 2013-10-27-backup-all-virtual-machines-on-a-smartos-hypervisor-with-smart-back-sh.rst modified: 2013-12-13-hackathon-2013-virtualization.rst modified: 2013-12-17-sensu-salt.rst modified: 2014-01-02-test-game-engine-with-python-and-sfml.rst modified: 2014-01-25-how-to-reset-hp-ilo-lights-out-user-and-password-settings-with-ipmitools.rst modified: 2014-02-21-configuration-management-and-the-golden-image.rst modified: 2014-03-08-replace-the-nagios-scheduler-and-nrpe-with-salt-stack.rst modified: 2014-04-08-how-to-patch-heartbleed-openssl-defect-libssl-on-ubuntu.rst modified: 2014-08-23-heka-world2.rst modified: 2014-12-03-custom-rundeck-hipchat-notification-templates.rst modified: 2015-02-22-securely-publish-jenkins-build-artifacts-on-salt-master.rst modified: 2015-05-08-a-python-script-which-searches-for-available-interpreters.rst modified: 2015-11-15-migrating-from-wordpress-to-pelican.rst modified: 2016-06-21-output-all-instance-identifiers-of-an-aws-vpc-to-json.rst modified: 2016-11-21-sharing-a-pyramid-cookie-with-flask-or-tornado.rst
115 lines
3.2 KiB
ReStructuredText
115 lines
3.2 KiB
ReStructuredText
A system administrators guide to installing and maintaining multiple python environments
|
|
########################################################################################
|
|
|
|
:date: 2011-09-08 19:28
|
|
:author: Russell Ballestrini
|
|
:tags: DevOps, Guide
|
|
:slug: a-system-administrators-guide-to-installing-and-maintaining-multiple-python-environments
|
|
:status: published
|
|
|
|
.. contents::
|
|
|
|
Some operating systems depend on a specific version of python to
|
|
function properly. For example, Yum on Redhat Enterprise Linux 5 (RHEL5)
|
|
depends on python 2.4.3. This version of python lacks support from many
|
|
utilities and 3rd party libraries. This guide will cover installing an
|
|
alternative python instance while leaving the system's python alone.
|
|
|
|
*This guide supports the following operating systems: Redhat, CentOS,
|
|
and Fedora. As of this publication the latest Python version was 2.7.8;
|
|
You might want to determine if a newer version exists.*
|
|
|
|
Install Python 2.7
|
|
==================
|
|
|
|
I found two methods which work for installing Python 2.7 side-by-side with the system's Python.
|
|
|
|
* compile from source
|
|
* install package via the *scl* repo
|
|
|
|
Choose which ever strategy you find easier.
|
|
|
|
Compile from source
|
|
-------------------
|
|
|
|
#. Gather the dependencies::
|
|
|
|
yum install gcc zlib-devel python-setuptools readline-devel
|
|
|
|
- **gcc** is a compiler used to build python
|
|
- **zlib-devel** allows the python zlib module to be built
|
|
- **python-setuptools** provides the easy_install application
|
|
- **readline-devel** arrows readline and history handling in python shell
|
|
|
|
#. Download and untar the python sourcecode::
|
|
|
|
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
|
|
tar -xzvf Python-2.7.8.tgz
|
|
cd Python-2.7.8
|
|
|
|
|
|
#. Compile the sourcecode::
|
|
|
|
./configure
|
|
make altinstall
|
|
|
|
#. Test new alternative python::
|
|
|
|
python2.7 --version
|
|
|
|
#. Document path to new python2.7, you will need it if you plan to use a virtualenv::
|
|
|
|
which python2.7
|
|
|
|
#. Now we can install third party libraries into our alternative python::
|
|
|
|
python2.7 -m easy_install
|
|
|
|
Install package from scl
|
|
------------------------
|
|
|
|
#. install centos-release-scl repolists::
|
|
|
|
sudo yum install centos-release-scl
|
|
|
|
#. install python27::
|
|
|
|
sudo yum install python27
|
|
|
|
#. enable python27 via scl::
|
|
|
|
scl enable python27 bash
|
|
|
|
#. Document path to new python2.7, you will need it if you plan to use a virtualenv::
|
|
|
|
which python2.7
|
|
|
|
|
|
virtualenv
|
|
==========
|
|
|
|
Optionally we can create a virtualenv (for development) based on the
|
|
python 2.7 install. Virtual environments appear useful for testing
|
|
packages and libraries without installing them to the system owned
|
|
python site-packages directory.
|
|
|
|
#. Install pip using easy\_install::
|
|
|
|
sudo easy_install pip
|
|
|
|
#. Install virtualenv using pip::
|
|
|
|
sudo pip install virtualenv
|
|
|
|
#. Create a new virtual python environment named virtpy::
|
|
|
|
cd ~
|
|
virtualenv -p /usr/local/bin/python2.7 virtpy
|
|
|
|
This will create a virtual python 2.7.2 environment named virtpy in your present working directory.
|
|
|
|
To invoke this environment run source virtpy/bin/activate and your prompt should change to reflect the active virtualenv.
|
|
|
|
Now you can run easy_install to install packages into virtpy/lib/python2.7/site-packages.
|
|
|
|
**Thanks for reading, that's all for now.**
|