简体   繁体   English

Debian中的多个Python版本

[英]Multiple Python versions in Debian

Im trying to manage multiple python versions in Debian 8, Python 2.7 (default) and 2.6. 我试图在Debian 8,Python 2.7(默认)和2.6中管理多个python版本。 The problem is, i dont now how to do correctly for installing modules in the 2.6 version. 问题是,我现在不知道如何正确安装2.6版本的模块。 pip is deprecated for 2.6. pip已弃用2.6。

virtualenv is a tool to create isolated Python environments. virtualenv是用于创建隔离的Python环境的工具。

The basic problem being addressed is one of dependencies and versions, and indirectly permissions. 解决的基本问题是依赖项和版本之一,以及间接权限。 Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? 假设您有一个需要使用LibFoo版本1的应用程序,但是另一个应用程序需要版本2。您如何同时使用这两个应用程序? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded. 如果将所有内容都安装到/usr/lib/python2.7/site-packages(或平台的标准位置是什么)中,那么很容易在无意中升级不应升级的应用程序的情况下结束。

Or more generally, what if you want to install an application and leave it be? 或更笼统地说,如果您要安装应用程序并保留原样该怎么办? If an application works, any change in its libraries or the versions of those libraries can break the application. 如果应用程序正常运行,则其库或这些库的版本中的任何更改都可能破坏应用程序。

Also, what if you can't install packages into the global site-packages directory? 另外,如果无法将软件包安装到全局site-packages目录中怎么办? For instance, on a shared host. 例如,在共享主机上。

In all these cases, virtualenv can help you. 在所有这些情况下,virtualenv都可以为您提供帮助。 It creates an environment that has its own installation directories, that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either). 它创建了一个具有自己的安装目录的环境,该环境不与其他virtualenv环境共享库(也可以选择不访问全局安装的库)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM