zoukankan      html  css  js  c++  java
  • 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'
  • 相关阅读:
    信息安全系统设计基础第十二周学习总结
    day07-流程控制之while循环
    day07-深浅拷贝
    第一次小测
    day05-与用户交互与运算符
    day05学习笔记-垃圾回收机制
    day04学习笔记-变量
    day03-python-学习笔记
    P4323-[JSOI2016]独特的树叶【换根dp,树哈希】
    CF990G-GCD Counting【dfs】
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15664939.html
Copyright © 2011-2022 走看看