Home Backend Development Python Tutorial python3 install pip3 (install pip3 for python 3.x)

python3 install pip3 (install pip3 for python 3.x)

Jun 02, 2018 pm 03:17 PM
install pip3 python3

This article mainly introduces install pip3 for python 3.x in detail, which has certain reference value. Interested friends can refer to it

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 it is learning or using python, python3 is currently the first choice. Then the problem arises. ---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!!)

1. Install python3 first

Install python3.x I won’t go into details here, 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, a Python folder will be generated under /opt/. Yes, this is the compiled python - for convenience Friends can define a soft connection 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 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 python bin directory

# #Ha ha. . 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 &#39;pymysql&#39; ##没有此模块奥
>>>
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 this module is actually installed on python3 (it may be 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! !

The above is the detailed content of python3 install pip3 (install pip3 for python 3.x). 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)

3 Easy Ways to Create a Windows 11 USB Installer on Mac 3 Easy Ways to Create a Windows 11 USB Installer on Mac May 13, 2023 pm 09:43 PM

Windows 11 introduces a wealth of new features and a comprehensively improved appearance, placing greater emphasis on unity and efficiency. So, today’s topic is how to create a Windows 11 USB installer on Mac. Performing a clean installation of Windows 11, rather than an upgrade, is the method that yields the best results when getting the operating system. Using a drive bootable in Windows 11, you can perform this task. If you have a Windows PC, making a bootable CD for Windows 11 is a very simple process. On the other hand, if you are using a Mac, the process is a little more complicated. This article will describe how to use the base

How to install macOS on a new SSD How to install macOS on a new SSD Apr 13, 2023 pm 04:01 PM

How to Use macOS Recovery to Install macOS on a New SSD On any Mac built after 2009, there is a built-in recovery system. This allows you to boot your Mac into recovery mode. In this mode, you can repair the internal disk, restore files from a Time Machine backup, get online help, or reinstall macOS. You must have an Internet connection to use these tools. You can use the macOS installation tool to install macOS on a new SSD installed in your computer. To use Internet Recovery to install macOS on an SSD: Follow the manufacturer's instructions

How to install PHP on Windows 10 using Command Prompt How to install PHP on Windows 10 using Command Prompt May 08, 2023 pm 05:13 PM

Install PHP on Windows using Command Prompt or PowerShell Install ChocolateyChoco Package Manager I tried the Windows default package manager Winget but could not install PHP through it. Therefore, the other best option left is to use the popular Chocolatey package manager. But unlike Winget, Choco does not exist in our Windows system by default, so we need to install it manually on our system. Go to your Windows 10 or 11 search box and type CMD, when it appears select "Run as administrator" to copy the given command

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.

The Linux-compatible Windows Subsystem is now generally available in the Microsoft Store. The Linux-compatible Windows Subsystem is now generally available in the Microsoft Store. Apr 23, 2023 pm 07:19 PM

Microsoft brings Windows Subsystem for Linux (WSL) to the Microsoft Store on Windows 11 in preview status. For those who don’t know, WSL is a very useful feature that Microsoft added to Windows 10 in 2017. It enables developers to run GNU/Linux environments directly within Windows without the need for a virtual machine (VM) or dual-boot configuration. Today, the company has made WS generally available in the Microsoft Store for Windows 10 and Windows 11

How to install pip in python3 How to install pip in python3 Dec 20, 2023 pm 05:42 PM

Installation steps: 1. Make sure that Python3 has been installed and can be accessed through the command line; 2. Open the terminal and enter the "python3 -m ensurepip --upgrade" command to install pip; 3. Download the pip installation package from the official Python website; 4. Extract the downloaded pip installation package into a directory; 5. Open the terminal and navigate to the decompressed pip directory; 6. Run the "python3 setup.py install" command to install pip.

How to install Sensu Go Monitoring on Windows 11 or 10 via WSL How to install Sensu Go Monitoring on Windows 11 or 10 via WSL Apr 13, 2023 pm 12:49 PM

Steps to Install Sensu Go on Windows 10 or 11 To start using the Sensu Go monitoring tool on Windows 11 or 10, your system should have 10 GB of free space and 4GB of RAM. However, if you are in a production environment, 8GB RAM is recommended. 1. Enable WSL on Windows 11 or 10 Here we are using Ubuntu 22.04 on Windows

pip3 installation tutorial pip3 installation tutorial Dec 19, 2023 pm 01:19 PM

The steps of pip3 installation are divided into three steps: "check", "installation" and "verification": 1. Run the "python3 --version" command in the command line to check the version of Python3; 2. Open a browser to download "get -pip.py" script file, open the terminal, navigate to the file directory, and run the "python3 get-pip.py" command; 3. Run the "pip3 --version" command on the command line to verify whether pip3 is installed successfully.

See all articles