- Mastering Python
- Rick van Hattem
- 296字
- 2021-07-16 11:10:31
Bootstrapping pip using ensurepip
Slowly, the pip
package manager has been replacing easy_install
since its introduction in 2008. Since Python 3.4, it has even become the default and is bundled with Python. Since Python 3.4 onward, it is installed by default within both the regular Python environment and that of pyvenv
; before that, a manual install is required. To automatically install pip
in Python 3.4 and above, the ensurepip
library is used. This is a library that handles automatic installation and/or upgrades of pip
, so it is at least as recent as the one bundled with ensurepip
.
ensurepip usage
The usage of ensurepip
is fairly straightforward. Just run python -m ensurepip
to guarantee a pip
version or python -m ensurepip --upgrade
to make sure that pip
will be at least the version that is bundled with ensurepip
.
In addition to installing the regular pip
shortcut, this will also install the pipX
and pipX.Y
links, which allow you to select a specific Python version. When using Python 2 and Python 3 simultaneously, this allows you to install packages within Python 2 and Python 3 with pip2
and pip3
, respectively. This means that if you use python -m ensurepip
on Python 3.5 you will get pip
, pip3
, and pip3.5
commands installed in your environment.
Manual pip install
The ensurepip
package is great if you are using Python 3.4 or above. Below that, however, you need to install pip
manually. Actually, this is surprisingly easy. It involves just two steps:
- Download the
get-pip.py
file: https://bootstrap.pypa.io/get-pip.py. - Execute the
get-pip.py
file: pythonget-pip.py
.
- The Modern C++ Challenge
- 深入理解Django:框架內(nèi)幕與實(shí)現(xiàn)原理
- INSTANT FreeMarker Starter
- C語(yǔ)言從入門到精通(第4版)
- Android 應(yīng)用案例開發(fā)大全(第3版)
- Python數(shù)據(jù)分析從0到1
- Mastering ServiceNow(Second Edition)
- Learning Material Design
- Raspberry Pi Robotic Blueprints
- 零基礎(chǔ)輕松學(xué)C++:青少年趣味編程(全彩版)
- Android移動(dòng)應(yīng)用開發(fā)項(xiàng)目教程
- 分布式架構(gòu)原理與實(shí)踐
- C語(yǔ)言程序設(shè)計(jì)
- 深入理解Java虛擬機(jī):JVM高級(jí)特性與最佳實(shí)踐
- TypeScript全棧開發(fā)