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 252020, 23:03:10) [MSC v.191664 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 252020, 23:03:10) [MSC v.191664 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\*
python干嘛用的d:\programs\python\
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 252020, 23:03:10) [MSC v.191664 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'

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。