在 Debian 上安装第二个 python

发布于 2024-11-05 09:37:54 字数 211 浏览 9 评论 0原文

所以我有 Debian 机器作为我的 Django 生产服务器。 我需要安装第二个 python (2.7.1) 才能与 virtualenv 一起使用。 但它总是写我没有一些模块,然后我必须手动搜索,apt-install它们并重建。有没有办法解决构建的依赖关系,或者使用 python 2.7.1 为 Debian Squeeze 预编译 .deb? 抱歉,如果这是一个菜鸟问题,老实说,我用谷歌搜索过。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

回心转意 2024-11-12 09:37:54

获取 Python 2.7.1 源代码并手动编译:

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

Get the Python 2.7.1 sources and compile it manually:

configure --prefix=/path/to/python-2.7
make; make install
抱猫软卧 2024-11-12 09:37:54

Python 2.7 可用于 wheezy(测试),因此您应该能够安装通过添加 testing 存储库并执行一些 APT 固定

1) 在 /etc/apt/sources.list 中添加存储库

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

2) 在 /etc/apt/preferences 中进行实际固定

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

A Pin-优先级低于500基本上意味着不会自动安装来自testing的软件包,因此其他软件包不会出现问题。

3) 安装python2.7 来自 testing

aptitude -t testing install python2.7

(如果您没有 aptitude,则使用 apt-get

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)

二智少女猫性小仙女 2024-11-12 09:37:54

以下是 Debian GNU/Linux 6.0.7(2013 年 7 月 18 日)的两种方法:

经典的

安装依赖项

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 

下载 python

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

编译

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

安装

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

测试

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

升级 pip virtualenv

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

创建用户及其 virtualenv

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

再次测试

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

“pythonic”

使用包 pyenv

 pyenv install 2.7.5

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
长途伴 2024-11-12 09:37:54

使用 debootstrap 安装 chroot 环境也是一种快速且安全的解决方案。
它使用约300mb

debootstrap wheezy /opt/debian7
chroot /opt/debian7
apt-get install python2.7

Installing a chroot-environment with debootstrap could be also a fast and secure solution.
It uses about 300mb

debootstrap wheezy /opt/debian7
chroot /opt/debian7
apt-get install python2.7
戏剧牡丹亭 2024-11-12 09:37:54

您可以使用pythonbrew安装和切换python版本我在Debian 6和Debian 7中安装了python 2.7.3和python 2.7.9并且工作正常。
您可以按照本教程pythonbrew howto

You can install and switch python versions using pythonbrew I installed python 2.7.3 and python 2.7.9 in Debian 6 and Debian 7 and works fine.
You can follow this tutorial pythonbrew howto

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文