Home Backend Development Python Tutorial Detailed explanation of the steps to install pip3 in python3

Detailed explanation of the steps to install pip3 in python3

Apr 09, 2018 am 11:01 AM
pip3 python3 Detailed explanation

This time I will bring you python3 a detailed explanation of the steps to install pip3, what are the precautions for installing pip3 in python3, the following is a practical case, let's take a look.

Foreword:

The server I am currently using is centos6.x. The version of python that comes with the system is 2.6.x. However, whether I am learning or using python, python3 is the first choice, so here comes the problem. ---How to install the python3 environment, and how to install the corresponding pip3 for python3? More importantly, there are some built-in tools in our original system that require the python2.6 version, so the coexistence of python3 and python2, and the coexistence of pip2 and pip3 are required. The following article is my personal practice. (Install pip3 for python3)

The purpose of writing this article is to help comrades who also encounter the same problem (currently it is difficult to find information on the Internet, and most of it has not been practiced. The following is my experience, 100% Can succeed! Go! Go!)

##First, install python3.x, so easzy! ! 1. First go to the official website to download the python3 installation package

Official website address ---I downloaded Python-3.5.2.tar.xz

2. Upload Package to server

3. Unzip

tar -xf Python-3.5.2.tar.xz
Copy after login

4. Compile and install

! ! ! ! Pay attention

⚠️ You need to install some necessary dependencies before compiling, otherwise you have to recompile when an error is reported---(I suffered this loss, so be careful...)Install the necessary dependencies (at least the following two are required, I personally encountered the following two)

yum install openssl-devel -y
yum install zlib-devel -y
Copy after login
Okay, now you can compile with peace of mind:

cd Python-3.5.2
./configure --prefix=/opt/Python  #安装目录可以自己定义无所谓。
make
make install
Copy after login

After the compilation is completed, it will Generate a Python folder under /opt/. Yes, this is the compiled python - for convenience, friends can define a soft link as follows:

# ln -s /opt/Python/bin/python3 /usr/bin/python3
Copy after login

In this way, you can directly consume python3 As follows:

Okay so far, our task of installing python3 under Linux has been completed. Let’s enter the key point and install pip3 for python3

2. install pip for python3.x

In fact, this is not difficult. . Download several packages and execute two commands to get it done. 1. First install setuptools

Friends can download it through the official module library: Download address

Here I directly use wget to download the version 19.6 from the server (Friends, you can try the new version...)

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6.tar.gz
python3 setup.py build
python3 setup.py install
Copy after login

2. Then install pip directly and you're done. .

Similarly download it first and then execute the command to get it done! !

wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2
python3 setup.py build
python3 setup.py install
Copy after login

After the installation is complete, let’s take a look at what is in the bin directory of python

Haha. . Through the above we have installed pip3 for python3. . . (Friends can also make a soft connection for convenience and practicality...)

3. Let’s do a test

1. First, let’s enter python3

[root@centos3 bin]# python3
Python 3.5.2 (default, Jul 27 2016, 03:36:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named 'pymysql' ##没有此模块奥
>>>
Copy after login
Okay, let’s try to install it with the newly installed pip3:

[root@centos3 bin]# /opt/Python/bin/pip3 install pymysql
Collecting pymysql
 Downloading PyMySQL-0.7.5-py2.py3-none-any.whl (77kB)
 100% |████████████████████████████████| 81kB 3.2kB/s 
Installing collected packages: pymysql
Successfully installed pymysql-0.7.5
######安装完成
Copy after login

The installation is complete. It seems that there is no problem with pip3 itself. Let’s test whether it is really installed for python3. Module (maybe it is installed on python2...-_-#)

[root@centos3 bin]# python3
Python 3.5.2 (default, Jul 27 2016, 03:36:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
>>>
Copy after login

Hahaha ok. . Finish! !

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to implement Mahalanobis distance in Python

##The perfect solution to the inability to use pip in python2.7

The above is the detailed content of Detailed explanation of the steps to install pip3 in python3. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of the mode function in C++ Detailed explanation of the mode function in C++ Nov 18, 2023 pm 03:08 PM

Detailed explanation of the mode function in C++ In statistics, the mode refers to the value that appears most frequently in a set of data. In C++ language, we can find the mode in any set of data by writing a mode function. The mode function can be implemented in many different ways, two of the commonly used methods will be introduced in detail below. The first method is to use a hash table to count the number of occurrences of each number. First, we need to define a hash table with each number as the key and the number of occurrences as the value. Then, for a given data set, we run

Detailed explanation of obtaining administrator rights in Win11 Detailed explanation of obtaining administrator rights in Win11 Mar 08, 2024 pm 03:06 PM

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

Detailed explanation of division operation in Oracle SQL Detailed explanation of division operation in Oracle SQL Mar 10, 2024 am 09:51 AM

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

Detailed explanation of remainder function in C++ Detailed explanation of remainder function in C++ Nov 18, 2023 pm 02:41 PM

Detailed explanation of the remainder function in C++ In C++, the remainder operator (%) is used to calculate the remainder of the division of two numbers. It is a binary operator whose operands can be any integer type (including char, short, int, long, etc.) or a floating-point number type (such as float, double). The remainder operator returns a result with the same sign as the dividend. For example, for the remainder operation of integers, we can use the following code to implement: inta=10;intb=3;

Detailed explanation of the usage of Vue.nextTick function and its application in asynchronous updates Detailed explanation of the usage of Vue.nextTick function and its application in asynchronous updates Jul 26, 2023 am 08:57 AM

Detailed explanation of the usage of Vue.nextTick function and its application in asynchronous updates. In Vue development, we often encounter situations where data needs to be updated asynchronously. For example, data needs to be updated immediately after modifying the DOM or related operations need to be performed immediately after the data is updated. The .nextTick function provided by Vue emerged to solve this type of problem. This article will introduce the usage of the Vue.nextTick function in detail, and combine it with code examples to illustrate its application in asynchronous updates. 1. Vue.nex

Detailed explanation of the role and usage of PHP modulo operator Detailed explanation of the role and usage of PHP modulo operator Mar 19, 2024 pm 04:33 PM

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus

Detailed explanation of the linux system call system() function Detailed explanation of the linux system call system() function Feb 22, 2024 pm 08:21 PM

Detailed explanation of Linux system call system() function System call is a very important part of the Linux operating system. It provides a way to interact with the system kernel. Among them, the system() function is one of the commonly used system call functions. This article will introduce the use of the system() function in detail and provide corresponding code examples. Basic Concepts of System Calls System calls are a way for user programs to interact with the operating system kernel. User programs request the operating system by calling system call functions

What are the differences between pip and pip3? What are the differences between pip and pip3? Dec 07, 2023 pm 03:17 PM

The differences between pip and pip3 include version, installation path, compatibility, default installation method, Python version used, command line format, package manager used, installation path, update method, etc. Detailed introduction: 1. pip is the package management tool in Python 2.7.9 and later versions, pip3 is the package management tool in Python 3.4 and later versions; 2. The pip installation path is in the Scripts folder of Python, and pip3 is in Python3’s Scripts folder, etc.

See all articles