python使用pip卸载和安装库「建议收藏」

python使用pip卸载和安装库「建议收藏」pip先来演示pip的错误打开方式:C:\Users\86188>pyPython3.8.2(tags/v3.8.2:7b3ab59,Feb252020,22:45:29)[MSCv.191632bit(Intel)]onwin32Type”help”,”copyright”,”credits”or”license”formoreinformation.>>>pipTraceback(mostrecentcalllast

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

pip

先来演示pip的错误打开方式:

C:\Users\86188>py
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'pip' is not defined
>>>

问题出在哪呢?细心的同学会问了。其实呢,pip虽然是python的自带工具,而且安装了python之后会自动安装上pip,但pip工具并不能在python中打开哦!
下面我们演示如何在命令行中退出python,之后打开pip:

>>> exit()

C:\Users\86188>pip

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  cache                       Inspect and manage pip's wheel cache.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to
                              WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 6000.0 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
                              (a)bort.
  --trusted-host <hostname>   Mark this host or host:port pair as trusted, even though it does not have valid or any
                              HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the
                              certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for
                              download. Implied with --no-index.
  --no-color                  Suppress colored output
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported Pythons.

C:\Users\86188>

先输入exit(),回车,我们就从python的界面退出了。
接着输入pip回车,就出现了长达一整页的提示,其中包括了install、uninstall等,都是可以使用pip完成的功能。
那么我们来用pip卸载一个库吧!首先,以绘图工具pandas为例来试一试:

C:\Users\86188>pip uninstall pandas
Found existing installation: pandas 1.0.5
Uninstalling pandas-1.0.5:
  Would remove:
    c:\users\86188\appdata\local\programs\python\python38-32\lib\site-packages\pandas-1.0.5.dist-info\*
    c:\users\86188\appdata\local\programs\python\python38-32\lib\site-packages\pandas\*
Proceed (y/n)? 

输入pip uninstall pandas,会看到命令行出现以上反应,并且会有一个”继续(是/否)的提示,此时如果我们输入y并按回车,卸载进程就会继续,如果我们输入n并按回车,卸载过程就会停止。
我输入了y和回车,结果如下:

 Proceed (y/n)? y
  Successfully uninstalled pandas-1.0.5

接下来我们再来安装,输入“pip install pandas”,可以看到如下界面:

C:\Users\86188>pip install pandas
Looking in indexes: http://pypi.douban.com/simple
Collecting pandas
  Downloading http://pypi.doubanio.com/packages/0d/3b/c306fc4c669f9208ba5a62d29a71fcb5df3be80a914da9e7b30ad682589f/pandas-1.0.5-cp38-cp38-win32.whl (7.6 MB)
     |████████████████████████████████| 7.6 MB 1.3 MB/s
Requirement already satisfied: numpy>=1.13.3 in c:\users\86188\appdata\local\programs\python\python38-32\lib\site-packages (from pandas) (1.19.0)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\86188\appdata\roaming\python\python38\site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\86188\appdata\local\programs\python\python38-32\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: six>=1.5 in c:\users\86188\appdata\roaming\python\python38\site-packages (from python-dateutil>=2.6.1->pandas) (1.14.0)
Installing collected packages: pandas
Successfully installed pandas-1.0.5

此时需要联网,进度条是下载的进度,Successfully installed pandas-1.0.5是”成功安装pandas-1.0.5版本“的意思。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/180218.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 无需Visual Studio,5容易的 – 分为报告

    无需Visual Studio,5容易的 – 分为报告

    2022年1月5日
    53
  • conversation pattern_inverted pattern

    conversation pattern_inverted patternSample<paramname=”ConversionPattern”value=”%d[%t]%-5p%c[%x]%X{auth}-Line:%L%m%n”/> %m(message):输出的日志消息%n(newline):換行%d(datetime):输出当前语句运行的时刻%r(runtime):输出程序从运行到执…

    2022年8月22日
    7
  • 数组的增删改查操作

    数组的增删改查操作

    2022年1月22日
    34
  • matplotlib用于标注文字的函数_python annotate

    matplotlib用于标注文字的函数_python annotateMatplotlib库标注在工作有很大作用:Annotate的构造函数为:Annotation(s,xy,xytext=None,xycoords=‘data’,textcoords=None,arrowprops=None,annotation_clip=None,**kwargs)用于绘制连接图上两点的箭头。关键参数:s为注释文本内容xy为被注释的坐标点,二维元组形如(…

    2025年6月6日
    4
  • sdio接口wifi模块_连接路由器的用哪个接口

    sdio接口wifi模块_连接路由器的用哪个接口SDIO-WiFi即基于SDIO接口符合WiFi标准的嵌入式模块,内置802.11协议栈以及TCP/IP协议栈,可实现主平台铜鼓SDIO到无线网络之间转换SDIO:传输数据块,兼容SD,MMC接口等先以SDIO设备注册,然后检测到再注册WiFi功能,即用SDIO协议发送命令和数据sdio基本概念接口1.SD的IO接口,透过SD的IO接口连接外设,透过SD卡的IO数据接位…

    2022年10月3日
    3
  • java编译报错提示编码GBK的不可映射字符啥意思_java字符串编码转换

    java编译报错提示编码GBK的不可映射字符啥意思_java字符串编码转换在我想要在println输出一些中文的时候,发现编码出现错误原因:java程序在编译的时候,需要使用JDK开发工具包中的JAVAC.EXE命令,而JDK开发工具包是国际版的,默认格式为UNICODE的编码格式。因此在默认情况下,javac.exe会采用默认的编码格式,什么是默认的编码格式呢?也就是我们在编译JAVA程序时,在未指定源程序文件的编码格式的情况下,JDK会优先获取操作系统的file.encoding参数,然后JDK就把我们的JAVA源程序从file.encoding编码格式转化为JAVA

    2025年11月7日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号