Skip to content

Instantly share code, notes, and snippets.

@ckandoth
Created November 29, 2016 22:12
Show Gist options
  • Save ckandoth/f25c7469f23e63e34bee346fcb10ec29 to your computer and use it in GitHub Desktop.
Save ckandoth/f25c7469f23e63e34bee346fcb10ec29 to your computer and use it in GitHub Desktop.
Download, install, and build Python 2.7.10 in a local folder
# Create a folder where you want to install different Pythons, and cd into it:
# Note that it doesn't need to be your home folder. Put it wherever you want to maintain such software:
export PYTHON_BASE="$HOME/python"
mkdir -p $PYTHON_BASE
cd $PYTHON_BASE
# Download source tarball into a subfolder named src, and untar:
curl --create-dirs -L -o src/Python-2.7.10.tgz https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
cd src
tar -zxf Python-2.7.10.tgz
# Configure, build, and install into a properly versioned subdirectory:
cd Python-2.7.10
./configure --prefix=$PYTHON_BASE/python-2.7.10 --enable-shared --enable-unicode=ucs4 LDFLAGS="-Wl,-rpath=$PYTHON_PREFIX/lib"
make
make install
# Make sure the latest setuptools and pip are installed:
$PYTHON_BASE/python-2.7.10/bin/python -m ensurepip
$PYTHON_BASE/python-2.7.10/bin/pip install --upgrade setuptools pip
# Install all the various packages we use here at MSKCC:
$PYTHON_BASE/python-2.7.10/bin/pip install --upgrade alabaster ansi argparse azure babel biopython drmaa filemagic fireworks fusepy ipython lockfile markerlib nose powerline-status pygments pyvcf sh snowballstemmer sphinx virtualenv wheel
$PYTHON_BASE/python-2.7.10/bin/pip install --upgrade pysam matplotlib pandas cython scipy
@youdar
Copy link

youdar commented Jan 19, 2018

Hi,
do you need to have root permission to perform this installation?

I get:

Creating directory /Python-2.7.14/bin
/usr/bin/install: cannot create directory `/Python-2.7.14': Permission denied
Creating directory /Python-2.7.14/lib
/usr/bin/install: cannot create directory `/Python-2.7.14': Permission denied
make: *** [altbininstall] Error 1

when running make install
Thanks

@arcolombo
Copy link

i get the same error.

@ederollora
Copy link

You probably need to run as sudo

@jose-nuno-sousa-alb
Copy link

This might help someone trying to run a local installation of python 2.7 to test some legacy code (the script is meant to be read and not blindly run):
old_python_install.sh

Leaving some final notes here for people having trouble:

  • You need to have SSL installed and available in your system for pip to work
  • If you define the environment variable DESTDIR before running make install you don't need sudo to install and it won't be installed with system files.
  • I recommend creating a virtualenv before installing extra packages, that way it is easier to clean up and/or test multiple requirements.
  • It shouldn't be said enough: Python 2.7.18 is the last of Python 2.x and it is no longer supported, so, do not use this installation for anything serious ...

Hope it helps!

@amidevous
Copy link

amidevous commented Nov 14, 2023

normal not use make install for python

for python use online

make altinstall

and for pip install not use

$PYTHON_BASE/python-2.7.10/bin/python -m ensurepip

use online

$PYTHON_BASE/python-2.7.10/bin/python -m ensurepip --altinstall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment