Installing Python on Linux(在 Linux 上安装 Python)

发布于 2022-05-14 12:40:12 字数 4713 浏览 1251 评论 0

The latest versions of Ubuntu and Fedora come with Python 2.7 out of the box.

最新版的Ubuntu和Fedora自带Python 2.7,直接使用。

The latest versions of Redhat Enterprise (RHEL) and CentOS come with Python 2.6. Some older versions of RHEL and CentOS come with Python 2.4 which is unacceptable for modern Python development. Fortunately, there are Extra Packages for Enterprise Linux which include high quality additional packages based on their Fedora counterparts. This repository contains a Python 2.6 package specifically designed to install side-by-side with the system’s Python 2.4 installation.

最新版的RHEL红帽子企业版和CentOS自带Python 2.6。一些老版本的系统自带Python 2.4,已经不能满足现代的Python开发者了。幸运的是,Extra Packages for Enterprise Linux包含基于Fedora系列的高质量附加包。这个仓库中包括一个Python 2.6的包,这是为与系统同时安装的Python 2.4特别设计的。

You do not need to install or configure anything else to use Python. Having said that, I would strongly recommend that you install the tools and libraries described in the next section before you start building Python applications for real-world use. In particular, you should always install Setuptools, as it makes it much easier for you to use other third-party Python libraries.

你不需要安装和配置任何东西就可以使用Python,话虽如此,在你开始构建实际使用的Python程序之前,我强烈建议你安装在下一节中描述的工具和库。特别的是,你最应该安装Setuptools,因为它可以让你非常轻易得使用其他第三方Python库。

Setuptools & Pip

The most crucial third-party Python software of all is Setuptools, which extends the packaging and installation facilities provided by the distutils in the standard library. Once you add Setuptools to your Python system you can download and install any compliant Python software product with a single command. It also enables you to add this network installation capability to your own Python software with very little work.

最重要的第三方Python软件就是Setuptools,它能够扩展由标准库中的distutils提供的包装和安装设施。一旦你添加Setuptools到你的Python系统中,仅需一条命令就可以下载和安装任何兼容的Python软件产品。它也让你可以通过很少的工作量就将这种网络安装能力添加到自己的Python软件中。

To obtain the latest version of Setuptools for Linux, refer to the documentation available here: unix-setuptools

为了获得最新的Linux版本Setuptools,参考文档:unix-setuptools

The new easy_install command you have available is considered by many to be deprecated, so we will install its replacement: pip. Pip allows for uninstallation of packages, and is actively maintained, unlike easy_install.

你现在拥有的新命令:easy_install已经被很多人弃用了,所以我们将安装它的替代品:pippipeasy_install好在它可以卸载一个包,还被积极维护着。

To install pip, simply open a command prompt and run:

为了安装pip,只需简单打开命令行运行:

$ easy_install pip

Virtual Environments(虚拟环境)

A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.

Virtual Environment是一种隔离依赖的工具,通过创建虚拟Python环境来保持不同项目在单独的地方。它解决了“项目X依赖版本1.x但是项目Y需要4.x”这种困境,可以保证你的总包目录是干净的和可管理的。

For example, you can work on a project which requires Django 1.3 while also maintaining a project which requires Django 1.0.

例如,你可以在一个依赖Django 1.3的项目上工具,也可以同时维护一个需要Django 1.0的项目。

To start using and see more information: Virtual Environments docs.

开始使用,查看更多信息:Virtual Environments 文档。

You can also use virtualenvwrapper to make it easier to manage your virtual environments.

你也可以使用 virtualenvwrapper,让它更容易管理你的虚拟环境。

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

JSmiles

生命进入颠沛而奔忙的本质状态,并将以不断告别和相遇的陈旧方式继续下去。

0 文章
0 评论
84960 人气
更多

推荐作者

qq_Yqvrrd

文章 0 评论 0

2503248646

文章 0 评论 0

浮生未歇

文章 0 评论 0

养猫人

文章 0 评论 0

第七度阳光i

文章 0 评论 0

新雨望断虹

文章 0 评论 0

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