Skip to content

Instantly share code, notes, and snippets.

@lukaslundgren
Created May 11, 2012 12:58
Show Gist options
  • Save lukaslundgren/2659457 to your computer and use it in GitHub Desktop.
Save lukaslundgren/2659457 to your computer and use it in GitHub Desktop.
How to install python 2.7 on debian
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr --enable-shared
make
sudo make install
cd ..
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
sudo update-alternatives --set python /usr/bin/python2.6
wget http://peak.telecommunity.com/dist/ez_setup.py
sudo python2.7 ez_setup.py
sudo easy_install-2.7 virtualenv
@deptadapt
Copy link

Hello again. I would like to ask that you remove this gist because it is profoundly bad advice for a Debian system.

Software installed locally should go to /usr/local. Only software installed by the package manager should live in /usr. The instructions here will conflict with upgrades from the package manager and leave the system in a broken state.

Please consider removing or correcting this gist. This is the second time I've encountered someone on IRC who has broken their Debian system following these instructions.

@jiska78
Copy link

jiska78 commented Aug 3, 2016

I get all this crap appearing:

Reading package lists... Done
Building dependency tree
Reading state information... Done
python is already the newest version.
python set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
8 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up python2.7-minimal (2.7.3-6+deb7u3) ...
Linking and byte-compiling packages for runtime python2.7...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in
from debpython.version import SUPPORTED, debsorted, vrepr,
ImportError: No module named debpython.version
dpkg: error processing python2.7-minimal (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-minimal:
python-minimal depends on python2.7-minimal (>= 2.7.3-1~); however:
Package python2.7-minimal is not configured yet.

dpkg: error processing python-minimal (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python2.7:
python2.7 depends on python2.7-minimal (= 2.7.3-6+deb7u3); however:
Package python2.7-minimal is not configured yet.

dpkg: error processing python2.7 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python:
python depends on python2.7 (>= 2.7.3-1~); however:
Package python2.7 is not configured yet.
python depends on python-minimal (= 2.7.3-4+deb7u1); however:
Package python-minimal is not configured yet.

dpkg: error processing python (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-cheetah:
python-cheetah depends on python2.7; however:
Package python2.7 is not configured yet.
python-cheetah depends on python (>= 2.6.6-7~); however:
Package python is not configured yet.
python-cheetah depends on python (<< 2.8); however:
Package python is not configured yet.

dpkg: error processing python-cheetah (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-configobj:
python-configobj depends on python2.7 | python2.6; however:
Package python2.7 is not configured yet.
Package python2.6 is not installed.
python-configobj depends on python (>= 2.6.6-7~); however:
Package python is not configured yet.
python-configobj depends on python (<< 2.8); however:
Package python is not configured yet.

dpkg: error processing python-configobj (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-feedparser:
python-feedparser depends on python2.7 | python2.6; however:
Package python2.7 is not configured yet.
Package python2.6 is not installed.
python-feedparser depends on python (>= 2.6.6-7~); however:
Package python is not configured yet.
python-feedparser depends on python (<< 2.8); however:
Package python is not configured yet.

dpkg: error processing python-feedparser (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-pkg-resources:
python-pkg-resources depends on python (>= 2.6); however:
Package python is not configured yet.
python-pkg-resources depends on python (<< 2.8); however:
Package python is not configured yet.

dpkg: error processing python-pkg-resources (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python2.7-minimal
python-minimal
python2.7
python
python-cheetah
python-configobj
python-feedparser
python-pkg-resources
E: Sub-process /usr/bin/dpkg returned an error code (1)

@wassname
Copy link

wassname commented Apr 5, 2017

Just an update:

sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline-gplv2-dev libssl-dev libdb-dev tk-dev

On jesse libreadline5-dev is now libreadline-gplv2-dev . Also install tk-dev to make sure you get tkinker sys library.

@veralaub
Copy link

veralaub commented Jan 7, 2020

Thanks for this simple but lifesaving workflow! I was stupid enough to manually uninstall python2.7 but was able to recover it using this, saving me from the pain of completely setting up my system anew :).

@jahan-paisley
Copy link

@veralaub
I did the same mistake!
Thanks for sharing!

@bektigalan
Copy link

@wassname Package 'libreadline-gplv2-dev' has no installation candidate in Debian 12

@vanjy-eng
Copy link

@bektigalan
Found the answer here:
https://jira.mariadb.org/browse/MDEV-24798

replacing Package 'libreadline-gplv2-dev' with 'libeditreadline-dev' fixed the issue for me.

@bektigalan
Copy link

@bektigalan Found the answer here: https://jira.mariadb.org/browse/MDEV-24798

replacing Package 'libreadline-gplv2-dev' with 'libeditreadline-dev' fixed the issue for me.

thanks a lot @vanjy-eng i already solved it by downgrade my machine to debian 11, not exactly neat solution but saved me from headache

@ski007
Copy link

ski007 commented Jan 5, 2025

urllib2.HTTPError: HTTP Error 403: SSL is required ????

I tried installing on debian bookworm but on ARM orangepi / armbian

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