Standalone install of python 2.7 and 3.4 on CentOS

Download Python-2.7.6.tgz and Python-3.4.1.tar.xz. Unpack the xz-file with tar -xJvf Python-3.4.1.tar.xz. We use the standalone tcltk-installation we’ve made already… (here)

Python 2.7.6
./configure –prefix=/opt/python/2.7.6 –exec-prefix=/opt/python/2.7.6 –oldincludedir=/opt/python/2.7.6/include –datadir=/opt/python/2.7.6 –docdir=/opt/python/2.7.6/doc –with-system-ffi –with-tcltk-includes=”-I/opt/tcltk/8.5.13/include” –with-tcltk-libs=”-L/opt/tcltk/8.5.13/lib -ltcl8.5 -ltk8.5″ –with-pth

make -j4
make install

Module file /etc/modulefiles/python/2.7.6:

#%Module1.0##################################################
##
## Discretizer AB modulefile
##
##
proc ModulesHelp { } {
puts stderr “\tAdd environment.”
}

## Create a whatis file.
module-whatis “Add program links, aliases and paths”

setenv PYTHON_ROOT_DIR “/opt/python/2.7.6”
setenv PYTHONHOME “/opt/python/2.7.6”
setenv PYTHON_VERSION “2.7”
setenv PYTHON_INCLUDE /opt/python/2.7.6/include/python2.7
prepend-path PATH /opt/python/2.7.6/bin
prepend-path LD_LIBRARY_PATH /opt/python/2.7.6/lib
prepend-path PYTHONPATH /opt/python/2.7.6/lib/python2.7

Python 3.4.1
./configure –prefix=/opt/python/3.4.1 –exec-prefix=/opt/python/3.4.1 –oldincludedir=/opt/python/3.4.1/include –datadir=/opt/python/3.4.1 –docdir=/opt/python/3.4.1/doc –with-system-ffi –with-tcltk-includes=”-I/opt/tcltk/8.5.13/include” –with-tcltk-libs=”-L/opt/tcltk/8.5.13/lib -ltcl8.5 -ltk8.5″

make -j4
make install

module file /etc/modulefiles/python/3.4.1

#%Module1.0#########################################################
##
## Discretizer AB modulefile
##
##
proc ModulesHelp { } {
puts stderr “\tAdd environment.”
}

## Create a whatis file.
module-whatis “Add program links, aliases and paths”

set-alias “xmlwf” “xmlwf21”
set-alias “python” “python3”
set-alias “idle” “idle3”
set-alias “pip” “pip3”
set-alias “pydoc” “pydoc3”
set-alias “python-config” “python3-config”
set-alias “f2py” “f2py3”

setenv PYTHON_ROOT_DIR “/opt/python/3.4.1”
setenv PYTHONHOME “/opt/python/3.4.1”
setenv PYTHON_VERSION “3.4”
setenv PYTHON_INCLUDE /opt/python/3.4.1/include/python3.4
prepend-path PATH /opt/python/3.4.1/bin
prepend-path LD_LIBRARY_PATH /opt/python/3.4.1/lib
prepend-path PYTHONPATH /opt/python/3.4.1/lib/python3.4

Leave a Reply

Your email address will not be published. Required fields are marked *