• python中pip命令的使用


    python中pip命令主要用于安装和下载包

    安装:pip install package_name

    卸载:pip uninstall pakage_name

    以numpy包为例进行测试。

    1、查看python版本

    C:\Users\75377>python --version
    Python 3.8.2

    2、测试直接加载numpy包

    C:\Users\75377>python      ## 调用python
    Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy         ## 直接加载numpy,显示没有numpy模块
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'numpy'

    3、退出python,使用pip命令进行安装

    >>> quit()   ## 退出python
    
    C:\Users\75377>pip install numpy -y  ## 直接安装
    
    Usage:
      pip install [options] <requirement specifier> [package-index-options] ...
      pip install [options] -r <requirements file> [package-index-options] ...
      pip install [options] [-e] <vcs project url> ...
      pip install [options] [-e] <local project path> ...
      pip install [options] <archive url/path> ...
    
    no such option: -y      ## 不能使用 -y
    
    C:\Users\75377>pip install numpy   ## 安装 numpy
    Collecting numpy
      Using cached numpy-1.21.4-cp38-cp38-win_amd64.whl (14.0 MB)
    Installing collected packages: numpy
    Successfully installed numpy-1.21.4   ## 安装成功
    
    C:\Users\75377>

    4、测试效果

    C:\Users\75377>python
    Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy   ## 没有问题,可以调用
    >>>

    5、使用pip卸载 numpy

    >>> quit()
    
    C:\Users\75377>pip uninstall numpy    ## 卸载numpy包
    Found existing installation: numpy 1.21.4
    Uninstalling numpy-1.21.4:
      Would remove:
        d:\programs\python\lib\site-packages\numpy-1.21.4.dist-info\*
        d:\programs\python\lib\site-packages\numpy\*
        d:\programs\python\scripts\f2py.exe
    Proceed (Y/n)? y
      Successfully uninstalled numpy-1.21.4   ## 卸载成功

    6、测试卸载效果

    C:\Users\75377>python
    Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy   ## 卸载成功
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'numpy'
  • 相关阅读:
    Java并发编程 LockSupport源码分析
    [No000010F]Git8/9-使用GitHub
    [No000010E]Git7/9-标签管理
    [No000010D]Git6/9-分支管理
    [No000010C]Git5/9-远程仓库
    [No000010B]Git4/9-时光机穿梭
    [No000010A]Git3/9-创建版本库
    [No0000109]Git2/9-安装Git
    [No0000108]Git1/9-Git简介与入门
    [No000011D].NETCORE1/19-.NET Core 指南
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15664939.html
Copyright © 2020-2023  润新知