First, to make sure I started with a clean slate, I took the following steps:
- Uninstalled package
xlwt
(for testing), via sudo apt-get uninstall python-xlwt
and pip uninstall xlwt
- Uninstalled PIP via
sudo apt-get uninstall python-pip
- Made clean python source directory (~/src/Python2.7.8) via
make clean
- Made sure pip was not available via
which pip
(resulted in nothing)
To build Python 2.7.X and make sure PIP is configured for only that specific installation
- (assuming already downloaded and decompressed into home directory, say
~/src/Python2.7.8
)
- Make two directories for
--prefix
and --exec-prefix
configure options, say ~/bld/python2.7.8_ind
and ~/bld/python2.7.8_dep
Go to source directory (e.g. ~/src/Python2.7.8) and type
./configure --prefix=/home/uname/bld/python2.7.8_ind --exec-prefix=/home/uname/bld/python2.7.8_dep
type make && make install
The binary python
(or a symbolic link to the binary) for this installation is located in this example in /home/uname/bld/python2.7.8_dep/bin
This creates a (previously non-extant) directory bin
in ~/bld/python2.7.8_ind
and places the PIP executables there which will be used for this specific installation. The PIP packages are placed in ~/bld/python2.7.8_ind/lib/python2.7/site-packages
(which was previously empty save a README file).
Now, to install the first package to this specific python installation,
I verified that the directory ~/bld/python2.7.8_ind/lib/python2.7/site-packages
contains only packages added during PIP installation (pip, setuptools, easy_install)
- type
~/bld/python2.7.8_dep/bin/pip install xlwt
Now, the directory ~/bld/python2.7.8_ind/lib/python2.7/site-packages
contains a new package (xlwt).
Now when I type
~/bld/python2.7.8_dep/bin/python
>>> import xlwt
it works, and typing python
and import xlwt
produces an error (as expected). Also verify that path searched for packages by new python installation is correct with
~/bld/python2.7.8_dep/bin/python
>>> import site
>>> site.getsitepackages()
This whole process might have been obvious to non-newbies, but I'm a newbie so I've written it all out.