Python中Pip的安装操作

工具/原料

电脑,互联网,Python

方法/步骤

1、新建一个文本文档,起名为get-pip,后缀名该为.py

2、打开网址https://bootstrap.pypa.io/get-pip.py,复制所有文字到我们新建的文件get-pip.py中

部分代码:

#!/usr/bin/env python
#
# Hi There!
#
# You may be wondering what this giant blob of binary data here is, you might
# even be worried that we're up to something nefarious (good for you for being
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
# an entire copy of pip (version 22.3.1).
#
# Pip is a thing that installs packages, pip itself is a package that someone
# might want to install, especially if they're looking to run this get-pip.py
# script. Pip has a lot of code to deal with the security of installing
# packages, various edge cases on various platforms, and other such sort of
# "tribal knowledge" that has been encoded in its code base. Because of this
# we basically include an entire copy of pip inside this blob. We do this
# because the alternatives are attempt to implement a "minipip" that probably
# doesn't do things correctly and has weird edge cases, or compress pip itself
# down into a single file.
#
# If you're wondering how this is created, it is generated using
# `scripts/generate.py` in https://github.com/pypa/get-pip.

import sys

this_python = sys.version_info[:2]
min_version = (3, 7)
if this_python < min_version:
    message_parts = [
        "This script does not work on Python {}.{}".format(*this_python),
        "The minimum supported Python version is {}.{}.".format(*min_version),
        "Please use https://bootstrap.pypa.io/pip/{}.{}/get-pip.py instead.".format(*this_python),
    ]
    print("ERROR: " + " ".join(message_parts))
    sys.exit(1)


import os.path
import pkgutil
import shutil
import tempfile
import argparse
import importlib
from base64 import b85decode

Python中Pip的安装操作_第1张图片

3、打开cmd,找到get-pip.py文件的路径 ,然后输入python get-pip.py,敲回车就开始安装。

Python中Pip的安装操作_第2张图片

4、安装完成后,可以在cmd中输入pip list测试一下,显示如下信息就是安装成功了。

Python中Pip的安装操作_第3张图片

5、如果没有显示,则需要回到python的安装目录,将scripts目录加到path环境变量中,然后重启cmd

Python中Pip的安装操作_第4张图片

6、重新键入pip list或安装任意库进行测试

Python中Pip的安装操作_第5张图片

你可能感兴趣的:(python,pip,开发语言)