Python 官方文档:入门教程 => 点击学习
这篇文章主要介绍了使用python Pip的技巧有哪些的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇使用Python Pip的技巧有哪些文章都会有所收获,下面我们一起来看看吧。1.安装 pip从 Python
这篇文章主要介绍了使用python Pip的技巧有哪些的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇使用Python Pip的技巧有哪些文章都会有所收获,下面我们一起来看看吧。
从 Python 3.4 开始,pip 已经内置在 Python 中,因此无需再次安装。
如果你的 Python 版本没有 pip,可以使用以下两种方法安装它。
在命令行输入 easy_install pip,非常迅速。
从以下网址下载 pip 安装文件,然后将其提取到 Python 脚本目录,并执行 python setup.py install 命令。
如果 pip 的版本太低,可以升级当前版本:pip install --upgrade pip 或 pip install -U pip。
$ pip install -U pipLooking in indexes: https://pypi.python.org/simpleRequirement already satisfied: pip in ./test/lib/python3.8/site-packages (21.1.1)Collecting pipUsing cached pip-22.0.4-py3-none-any.whl (2.1 MB)Installing collected packages: pipAttempting uninstall: pipFound existing installation: pip 21.1.1Uninstalling pip-21.1.1:Successfully uninstalled pip-21.1.1Successfully installed pip-22.0.4
使用 pip 安装第三方库,可以执行如下语句:pip install package_name
指定包版本:pip install package_name==1.1.2
比如,我要安装 3.4.1 版本的 matplotlib:pip install matplotlib==3.4.1
如果一个项目需要安装很多库,可以批量安装:pip install -r requirements.txt
文件的内容格式如下:
# This is a comment# Specify a diffrent index-i Http://dist.repoze.org/zope2/2.10/simple# Package with versionsTensorflow==2.3.1uvicorn==0.12.2fastapi==0.63.0pkg1pkg2pkg3>=1.0,<=2.0# It is possible to refer to specific local distribution paths../downloads/numpy-1.9.2-cp34-none-win32.whl# It is possible to refer to other requirement files or constraints files.-r other-requirements.txt-c constraints.txt# It is possible to specify requirements as plain names.pytestpytest-covbeautifulsoup4
已安装的库可以再次卸载:$ pip uninstall package_name
当前库的版本升级:
$ pip install --upgrade package_name
或
$ pip install -U package_name
有时您想输出当前环境中所有已安装的包,或生成一个需求文件,然后通过该文件在另一个环境中进行安装。您可以使用 pip freeze 命令:
# List packages$ pip freezedocutils==0.11Jinja2==2.7.2MarkupSafe==0.19Pygments==1.6Sphinx==1.2.2# Generate requirements.txt file$ pip freeze > requirements.txt
请注意,包会以排序顺序列出(不区分大小写)。如果您只想列出非全局安装的软件包,请使用 -l/--local。
您可以使用 pip show -f package_name 列出包信息:
$ pip show -f pyyamlName: PyYAMLVersion: 5.4.1Summary: YAML parser and emitter for PythonHome-page: https://pyyaml.org/Author: Kirill SimonovAuthor-email: xi@resolvent.netLicense: MITLocation: /private/tmp/test/lib/python3.8/site-packagesRequires:Required-by: awscliFiles:PyYAML-5.4.1.dist-info/INSTALLERPyYAML-5.4.1.dist-info/LICENSEPyYAML-5.4.1.dist-info/METADATAPyYAML-5.4.1.dist-info/RECORDPyYAML-5.4.1.dist-info/WHEELPyYAML-5.4.1.dist-info/top_level.txt...
在当前安装的库中,查看有哪些库需要进行版本升级:
$ pip list -oPackageVersion Latest Type---------- ------- ------ -----docutils 0.15.20.18.1 wheelPyYAML 5.4.1 6.0wheelrsa4.7.2 4.8wheelsetuptools 56.0.062.1.0 wheel
验证已安装的库的兼容性依赖,你可以使用 pip check package-name:
$ pip check awscliNo broken requirements found.
如果您不指定包名称,将检查所有包的兼容性。
$ pip checkpyramid 1.5.2 requires WEBOb, which is not installed.
将库下载到本地的指定位置并以 whl 格式保存:pip download package_name -d "path"
$ pip download PyYAML-d "/tmp/"Looking in indexes: https://pypi.python.org/simpleCollecting PyYAMLDownloading PyYAML-6.0-cp38-cp38-Macosx_10_9_x86_64.whl (192 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 192.2/192.2 KB 4.7 MB/s eta 0:00:00Saved ./PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whlSuccessfully downloaded PyYAML$ ls /tmp/PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl/tmp/PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl
关于“使用Python Pip的技巧有哪些”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“使用Python Pip的技巧有哪些”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程网Python频道。
--结束END--
本文标题: 使用Python Pip的技巧有哪些
本文链接: https://www.lsjlt.com/news/357126.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模
0