Installing Python 3 on Linux

Source: Internet
Author: User
Tags install openssl windows download

Build the Environment

1, Ubuntu14.04.5 Server, other versions are also available.
2, Python3.5.2.
3, theCentOS system installation Python3 in this tutorial also did the corresponding explanation.

Building Preparation

1. Download the installation package for Linux on the website of Python.
2, the following download method is the first in the Windows download the installation package and then upload to the virtual machine, you can also directly in the virtual machine using the wget command to download the installation package.

Download-1

Download-2 Download-3

3, download the good installation package.


Install package

4. Upload the installation package to the virtual machine (uploading path customization).


Uploading the installation package

5, another way to download, use the wget command to download the installation package, patiently wait for the download.

Wget

# Python3.5.2的wget命令示例wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz

6. View the installation package information.


Installation package Information Installation steps

1. On Linux operating system, we need to compile and install Python, we need to install GCC compiler.

# 单独安装gcc以及g++比较麻烦,幸运的是:# 为了能够编译Ubuntu的内核,Ubuntu提供了一个build-essential软件包apt-get install build-essential# 查看GCC的版本信息gcc --version# Centos系统安装GCC编译器yum -y install gcc

2, install the ReadLine module.

# 不安装该模块,编译安装后Python交互式无法使用退格键,方向键apt-get install libreadline6-dev

3. Unzip the tgz file and switch the directory.

Unzip and switch

# 解压到当前目录tar -zxvf Python-3.5.2.tgz# 切换到解压出的目录中cd Python-3.5.2/

4. Resolve the package required by the PIP Package Manager.

# Ubuntu系统apt-get install zlib1g zlib1g-dev# Centos系统yum install zlib zlib-devel# 修改"Modules/Setup"文件vim Modules/Setup.dist# 将下面1行取消注释,大概在文件的361行左右zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
Setup file
# Ubuntu系统apt-get install openssl libssl-dev# Centos系统yum install openssl openssl-devel

5. Start compiling the installation and customizing the installation directory.

# 创建安装目录mkdir -p /usr/local/python3.5.2# 指定到安装目录./configure --prefix=/usr/local/python3.5.2# 编译安装,耐心等待make && make install

6, modify the system built-in Python soft link.

# 删除原有的软链接rm -f /usr/bin/{python,python3}# 创建软链接ln -s /usr/local/python3.5.2/bin/python3.5 /usr/bin/pythonln -s /usr/local/python3.5.2/bin/python3.5 /usr/bin/python3# 创建PIP软链接ln -s /usr/local/python3.5.2/bin/pip /usr/bin/pip

7, for the CentOS system some problems
?? Package Explorer on Centos/redhat if yum, because the manager is implemented in the Python language, relies on the system installation Python2, we have modified the Python soft links built into the system, causing Yum cannot be used, here is the workaround:

# 修改yum命令的首行(默认脚本解释器)vim /usr/bin/yum# 示例原先为:"#!/usr/bin/python";修改后:"#!/usr/bin/python2.6";# 如果不知道系统自带python2的版本,可以使用以下命令查看ll /usr/bin/python*
Test action

1. View Python version information at the terminal:


Python version information install PIP Package Manager

1. The PIP Package Manager is already installed by default, and the following steps are prepared for readers who do not have Pip installed .
2, to the PIP website download get-pip.py.

View Scripts
?? I use the Google ChromeBrowser, installed Thunderbolt plugin, so you can directly use the Thunderbolt plug-in, if not have the plug-in, can be manually Copy link Address, used in the Thunderbolt NewDownload the script and upload it to the virtual machine.
11.png

2, execute the script get-pip.py, install PIP.

python get-pip.py

3, upgrade the PIP on Linux.

# 官网的教程有误python -m pip install -U pip



Installing Python 3 on Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.