Installing second python on Debian

So I have Debian machine for my Django production server. I need to install second python (2.7.1) to use with virtualenv. But it always write I don't have some modules, then I have to search manually, apt-install them and rebuild. Is there either a way to resolve the dependencies for building, or pre-compiled .deb with python 2.7.1 for Debian Squeeze? Sorry if this is much of a noobie question, I googled, honestly.


获取Python 2.7.1源并手动编译它:

configure --prefix=/path/to/python-2.7
make; make install

Python 2.7 is available for wheezy (testing), so you should be able to install it by adding the testing repository and doing some APT pinning.

1) add the repository in /etc/apt/sources.list

deb http://ftp.us.debian.org/debian testing main contrib non-free

2) do the actual pinning in /etc/apt/preferences

Package: *
Pin: release n=testing
Pin-Priority: 100

A Pin-Priority of under 500 basically means that no packages from testing are installed automatically, so you won't have problems with other packages.

3) install python2.7 from testing :

aptitude -t testing install python2.7

(or apt-get if you don't have aptitude )


Here is two methods for Debian GNU/Linux 6.0.7 (on 18/07/2013):

The classic

Install dependencies

aptitude -y install build-essential python-pip libmysqlclient-dev libadns1-dev 
 python-dev libreadline-dev libgdbm-dev zlib1g-dev libsqlite3-dev 
 libssl-dev libbz2-dev libncurses5-dev libdb-dev 

Download python

cd /tmp
wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.xz
unxz -c Python*xz | tar xpf -

Compile

cd Python*
./configure  --prefix=/opt/python2.7.5 --enable-shared
make

Install

make install
echo "/opt/python2.7.5/lib" >  /etc/ld.so.conf.d/libpython2.7.conf
ldconfig

Test

/opt/python2.7.5/bin/python -c "print('Ok')" 

Upgrade pip virtualenv

easy_install pip
pip -v install --upgrade distribute==0.7.3
pip -v install --upgrade virtualenv==1.9.1

Create an user and its virtualenv

adduser user_app --home /opt/user_app
su user_app
virtualenv --no-site-packages --verbose -p /opt/python2.7.5/bin/python $HOME

Test again

su user_app
cd 
source bin/activate
python -c "import sys; print sys.version"

The "pythonic"

Use the package pyenv.

 pyenv install 2.7.5
链接地址: http://www.djcxy.com/p/64054.html

上一篇: 为Arm / Raspberry Pi编译libsndfile

下一篇: 在Debian上安装第二个python