mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
Translated
This commit is contained in:
parent
73357843ee
commit
86411fdfd3
@ -1,113 +0,0 @@
|
||||
ucasFL translating
|
||||
How to Install Latest Python 3.6 Version in Linux
|
||||
============================================================
|
||||
|
||||
In this article we will show how to install and use Python 3.x in CentOS/RHEL 7, Debian and its derivatives such as Ubuntu (latest LTS version already has latest Python installed) or Linux Mint. Our focus will be installing the core language tools that can be used in the command line.
|
||||
|
||||
However, we will also explain how to install the Python IDLE – a GUI-based tool that allows us to run Python code and create standalone functions.
|
||||
|
||||
### Install Python 3.6 in Linux
|
||||
|
||||
At the time of this writing (mid-March 2017), the latest Python 3.x versions available in CentOS 7 and Debian 8are 3.4 and 3.5 respectively.
|
||||
|
||||
Although we can install the core packages and their dependencies using [yum][1] and [aptitude][2] (or [apt-get][3]), we will explain how to perform the installation from source instead.
|
||||
|
||||
Why? The reason is simple: this allows us to have the latest stable release of the language (3.6) and to provide a distribution-agnostic installation method.
|
||||
|
||||
Prior to installing Python in CentOS 7, let’s make sure our system has all the necessary development dependencies:
|
||||
|
||||
```
|
||||
# yum -y groupinstall development
|
||||
# yum -y install zlib-devel
|
||||
```
|
||||
|
||||
In Debian we will need to install gcc, make, and the zlib compression / decompression library:
|
||||
|
||||
```
|
||||
# aptitude -y install gcc make zlib1g-dev
|
||||
```
|
||||
|
||||
To install Python 3.6, run the following commands:
|
||||
|
||||
```
|
||||
# wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
|
||||
# tar xJf Python-3.6.0.tar.xz
|
||||
# cd Python-3.6.0
|
||||
# ./configure
|
||||
# make
|
||||
# make install
|
||||
```
|
||||
|
||||
Now relax and go grab a sandwich because this may take a while. When the installation is complete, use which to verify the location of the main binary:
|
||||
|
||||
```
|
||||
# which python3
|
||||
# python3 -V
|
||||
```
|
||||
|
||||
The output of the above command should be similar to:
|
||||
|
||||
[
|
||||
![Check Python Version in Linux](http://www.tecmint.com/wp-content/uploads/2017/03/Check-Python-Version-in-Linux.png)
|
||||
][4]
|
||||
|
||||
Check Python Version in Linux
|
||||
|
||||
To exit the Python prompt, simply type.
|
||||
|
||||
```
|
||||
quit()
|
||||
or
|
||||
exit()
|
||||
```
|
||||
|
||||
and press Enter.
|
||||
|
||||
Congratulations! Python 3.6 is now installed on your system.
|
||||
|
||||
### Install Python IDLE in Linux
|
||||
|
||||
Python IDLE is a GUI-based tool for Python. If you wish to install the Python IDLE, grab the package named idle (Debian) or python-tools (CentOS).
|
||||
|
||||
```
|
||||
# apt-get install idle [On Debian]
|
||||
# yum install python-tools [On CentOS]
|
||||
```
|
||||
|
||||
Type the following command to start the Python IDLE.
|
||||
|
||||
```
|
||||
# idle
|
||||
```
|
||||
|
||||
##### Summary
|
||||
|
||||
In this article we have explained how to install the latest Python stable version from source.
|
||||
|
||||
Last, but not least, if you’re coming from Python 2, you may want to take a look at the [2to3 official documentation][5]. This is a program that reads Python 2 code and transforms it into valid Python 3 code.
|
||||
|
||||
Do you have any questions or comments about this article? Feel free to get in touch with us using the form below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/install-python-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
|
||||
[1]:http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/
|
||||
[2]:http://www.tecmint.com/linux-package-management/
|
||||
[3]:http://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/03/Check-Python-Version-in-Linux.png
|
||||
[5]:https://docs.python.org/3.6/library/2to3.html
|
@ -0,0 +1,112 @@
|
||||
如何在 Linux 中安装最新的 Python 3.6 版本
|
||||
============================================================
|
||||
|
||||
在这篇文章中,我将展示如何在 CentOS/RHEL 7、Debian 以及它的衍生版本比如 Ubuntu(最新的 LTS(Ubuntu 16.04) 版本已经安装了最新的 Python 版本)或 Linux Mint 上安装和使用 Python 3.x 。我们的重点是安装可用于命令行的核心语言工具。
|
||||
|
||||
然而,我们也会阐述如何安装 Python IDLE - 一个基于 GUI 的工具,它允许我们运行 Python 代码和创建独立函数。
|
||||
|
||||
### 在 Linux 中安装 Python 3.6
|
||||
|
||||
在我写这篇文章的时候(2017 年三月中旬),在 CentOS 和 Debian 8 中可用的最新 Python 版本分别是 Python 3.4 和 Python 3.5 。
|
||||
|
||||
虽然我们可以使用 [yum][1] 和 [aptitude][2](或 [apt-get][3])安装核心安装包以及它们的依赖,但在这儿,我将阐述如何使用源代码进行安装。
|
||||
|
||||
为什么?理由很简单:这样我们能够获取语言的最新的稳定发行版(3.6),并且提供了一种和 Linux 版本无关的安装方法。
|
||||
|
||||
在 CentOS 7 中安装 Python 之前,请确保系统中已经有了所有必要的开发依赖:
|
||||
|
||||
```
|
||||
# yum -y groupinstall development
|
||||
# yum -y install zlib-devel
|
||||
```
|
||||
|
||||
在 Debian 中,我们需要安装 gcc、make 和 zlib 压缩/解压缩库:
|
||||
|
||||
```
|
||||
# aptitude -y install gcc make zlib1g-dev
|
||||
```
|
||||
|
||||
运行下面的命令来安装 Python 3.6:
|
||||
|
||||
```
|
||||
# wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
|
||||
# tar xJf Python-3.6.0.tar.xz
|
||||
# cd Python-3.6.0
|
||||
# ./configure
|
||||
# make
|
||||
# make install
|
||||
```
|
||||
|
||||
现在,放松一下,或者饿的话去吃个三明治,因为这可能需要花费一些时间。安装完成以后,使用 `which` 命令来查看主要二进制代码的位置:
|
||||
|
||||
```
|
||||
# which python3
|
||||
# python3 -V
|
||||
```
|
||||
|
||||
上面的命令的输出应该和这相似:
|
||||
|
||||
[
|
||||
![Check Python Version in Linux](http://www.tecmint.com/wp-content/uploads/2017/03/Check-Python-Version-in-Linux.png)
|
||||
][4]
|
||||
|
||||
*查看 Linux 系统中的 Python 版本*
|
||||
|
||||
要退出 Python 提示符,只需输入:
|
||||
|
||||
```
|
||||
quit()
|
||||
或
|
||||
exit()
|
||||
```
|
||||
|
||||
然后按 Enter 键。
|
||||
|
||||
恭喜!Python 3.6 已经安装在你的系统上了。
|
||||
|
||||
### 在 Linux 中安装 Python IDLE
|
||||
|
||||
Python IDLE 是一个基于 GUI 的 Python 工具。如果你想安装 Python IDLE,请安装叫做 idle(Debian)或 python-tools(CentOS)的包:
|
||||
|
||||
```
|
||||
# apt-get install idle [On Debian]
|
||||
# yum install python-tools [On CentOS]
|
||||
```
|
||||
|
||||
输入下面的命令启动 Python IDLE:
|
||||
|
||||
```
|
||||
# idle
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
在这篇文章中,我们阐述了如何从源代码安装最新的 Python 稳定版本。
|
||||
|
||||
最后但不是不重要,如果你之前使用 Python 2,那么你可能需要看一下 [从 Python 2 到 Python 3 的官方文档][5]。这是一个可以读入 Python 2 代码,然后转化为有效的 Python 3 代码的程序。
|
||||
|
||||
你有任何关于这篇文章的问题或想法吗?请使用下面的评论栏与我们联系
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Gabriel Cánepa - 一位来自阿根廷圣路易斯梅塞德斯镇 (Villa Mercedes, San Luis, Argentina) 的 GNU/Linux 系统管理员,Web 开发者。就职于一家世界领先级的消费品公司,乐于在每天的工作中能使用 FOSS 工具来提高生产力。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/install-python-in-linux/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[ucasFL](https://github.com/ucasFL)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
|
||||
[1]:http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/
|
||||
[2]:http://www.tecmint.com/linux-package-management/
|
||||
[3]:http://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/03/Check-Python-Version-in-Linux.png
|
||||
[5]:https://docs.python.org/3.6/library/2to3.html
|
Loading…
Reference in New Issue
Block a user