The editor believes that most people who are familiar with Python must have heard of and used the pip tool, but their understanding of it may not be very thorough. Today I will introduce to you 10 A little tip on using pip, I believe it will be helpful for you to manage and use the standard library in Python in the future.
Installation
Of course, after Python 3.4 and Python 2.7.9, the installation package on the official website already comes with pip, and users can use it directly after installing Python. , if you use a virtual environment created by virtualenv or pyvenv, then pip is also installed by default.
If you need to install the pip package yourself, run the following command line in an environment where Python has been configured.
py -m ensurepip --upgrade
Another way is to download it from the official website Download the get-pip.py script directly, and then run the python get-pip.py script directly
How to useAfter installation, enter pip in the command line, Then press Enter, and the instructions shown in the picture below will appear:pip install --upgrade pipor
pip install -U pipto install a certain version of the package If you plan to use pip to install third-party packages , the following command line is used
pip install package-nameFor example, we want to install a specified version of a third-party package, such as installing version 3.4.1 of matplotlib,
pip install matplotlib==3.4.1Uninstall or update the packageIf you plan to uninstall a certain package, the command line to enter is
pip uninstall package_nameand if you plan to update a certain package, the corresponding command line is
pip install --upgrade package_name# 或者是pip install -U package_nameView The information of a certain package can be viewed through the following command line.
pip show -f requestsoutput
Name: requests Version: 2.24.0 Summary: Python HTTP for Humans. Home-page: https://requests.readthedocs.io Author: Kenneth Reitz Author-email: me@kennethreitz.org License: Apache 2.0 Location: c:userspc120pycharmprojectspythonproject1venvlibsite-packages Requires: certifi, chardet, idna, urllib3 Required-by: etelemetry, gTTS, pandas-datareader, pandas-profiling, pyler, pywhatkit, pyxnat, streamlit, tushare, wikipedia, yfinance Files: requests-2.24.0.dist-infoDESCRIPTION.rst requests-2.24.0.dist-infoINSTALLER .......View the package that needs to be upgradedWe need to check it Among these existing packages, which ones need to be upgraded, you can use the following command line to check,
pip list -ooutput
PackageVersion Latest Type ---------- ------- ------ ----- docutils 0.15.20.18.1 wheel PyYAML 5.4.1 6.0wheel rsa4.7.2 4.8wheel setuptools 56.0.062.1.0 wheelCheck compatibility issues in When downloading and installing some standard libraries, you need to consider compatibility issues. The installation of some standard libraries may need to rely on other standard libraries, and there may be problems such as version conflicts. Let us first use the following command line to check whether there are conflicts. problem exists.
pip check package_nameOf course, if we do not specify which standard library it is, we will check whether there are version conflicts and other issues in all currently installed packages.
pip checkoutput
yfinance 0.1.70 has requirement requests>=2.26, but you have requests 2.24.0. selenium 4.1.0 has requirement urllib3[secure]~=1.26, but you have urllib3 1.25.11.Specify domestic sources to installIf we feel that the installation speed is a bit slow, we can specify domestic sources to install a certain package, such as
pip install -i https://pypi.douban.com/simple/ package_nameThere are domestic sources
清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:http://pypi.hustunique.com/ 山东理工大学:http://pypi.sdutlinux.org/ 豆瓣:http://pypi.douban.com/simple/Download the package but not install itIf we want to download a package to the specified path, the command line is as follows
pip download package_name -d "某个路径"For example,
pip download requests -d "."downloads the requests module and other dependent modules in the current directory. Batch installation of software packagesWhen we see other people's projects, we usually include a requirements.txt file, which contains some third-party libraries that need to be used in Python projects.
pip freeze > requirements.txtAnd if we need to install third-party libraries in batches, enter the following in the command line This command
pip install -r requirements.txt
The above is the detailed content of Detailed explanation of common pip commands in Python. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于Seaborn的相关问题,包括了数据可视化处理的散点图、折线图、条形图等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于进程池与进程锁的相关问题,包括进程池的创建模块,进程池函数等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于简历筛选的相关问题,包括了定义 ReadDoc 类用以读取 word 文件以及定义 search_word 函数用以筛选的相关内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于数据类型之字符串、数字的相关问题,下面一起来看一下,希望对大家有帮助。

VS Code的确是一款非常热门、有强大用户基础的一款开发工具。本文给大家介绍一下10款高效、好用的插件,能够让原本单薄的VS Code如虎添翼,开发效率顿时提升到一个新的阶段。

本篇文章给大家带来了关于Python的相关知识,其中主要介绍了关于numpy模块的相关问题,Numpy是Numerical Python extensions的缩写,字面意思是Python数值计算扩展,下面一起来看一下,希望对大家有帮助。

pythn的中文意思是巨蟒、蟒蛇。1989年圣诞节期间,Guido van Rossum在家闲的没事干,为了跟朋友庆祝圣诞节,决定发明一种全新的脚本语言。他很喜欢一个肥皂剧叫Monty Python,所以便把这门语言叫做python。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),