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'
分类:
python
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律