PIP command
The following is a pip command organized into a table and an example of its use:
Order | Usage example | illustrate |
---|---|---|
pip install <package> |
pip install requests |
Install the package named "requests" |
pip uninstall <package> |
pip uninstall requests |
Uninstall the package named "requests" |
pip list |
pip list |
List all packages installed in the current environment |
pip show <package> |
pip show requests |
View the detailed information of the package named "requests", including version number, installation path, etc. |
pip install --upgrade <package> |
pip install --upgrade requests |
Update the package named "requests" to the latest version |
pip search <package> |
pip search requests |
Search for packages named "requests" and display related information |
pip freeze > requirements.txt |
pip freeze > requirements.txt |
Export all packages installed in the current environment and their version numbers to a text file |
pip install -r requirements.txt |
pip install -r requirements.txt |
Batch install packages and their version numbers from a text file |
pip <command> --help |
pip install --help |
View help information for a specified command |
Note: The examples in the above table all use the "requests" package as an example. In actual use, you can replace it with the name of other packages as needed.
pip is Python's package management tool, which is used to install, uninstall and manage Python packages. It is a module in the Python standard library that provides a command line interface to easily search, install and update various Python packages.
Through pip, you can easily install third-party libraries and tools in the Python environment to extend the functionality of Python. It automatically resolves the package's dependencies and ensures that the required dependencies are installed.
pip also supports downloading and installing packages from PyPI (Python Package Index), a repository for shared code by the Python community. There are tens of thousands of open source packages to choose from on PyPI, covering a variety of fields and functions.
In addition to package installation and uninstallation, pip also provides other functions, such as viewing the installed package list, upgrading packages to the latest version, exporting the installed package list, etc.
All in all, pip is one of the essential tools for Python developers. It can simplify the process of package management and dependency management, making it easier for you to use and manage Python packages.
PIP usage-third-party library installation
Here are some commonly used Python third-party libraries and tools, and examples of installing them using pip:
Library name | Installation command | illustrate |
---|---|---|
NumPy | pip install numpy |
Library for scientific calculations and array operations |
Pandas | pip install pandas |
Provide high-performance, easy-to-use data structures and data analysis tools |
Matplotlib | pip install matplotlib |
Libraries for data visualization and plotting |
Requests | pip install requests |
Library for sending HTTP requests and communicating over the network |
Scikit-learn | pip install scikit-learn |
Libraries providing machine learning algorithms and tools |
TensorFlow | pip install tensorflow |
Open source libraries for deep learning and artificial intelligence |
Django | pip install django |
High-level Python framework for developing web applications |
Flask | pip install flask |
A lightweight web application framework suitable for building simple web applications |
SQLAlchemy | pip install sqlalchemy |
Library providing database access and ORM (Object Relational Mapping) functionality |
Beautiful Soup | pip install beautifulsoup4 |
Library for parsing HTML and XML documents, often used in web crawlers |
PyTorch | pip install torch |
An open source machine learning library for building deep learning models |
Selenium | pip install selenium |
A library for automated web testing that simulates user actions in the browser |
pytest | pip install pytest |
Library for writing and running Python unit tests |
Jupyter Notebook | pip install jupyter |
Provides an interactive data analysis and visualization environment that supports running code and displaying results. |
black | pip install black |
Tools for automatically formatting Python code |
Flask-RESTful | pip install flask-restful |
Rapid development of RESTful API extensions based on Flask |
Pillow | pip install pillow |
A library for image processing that supports operations such as opening, saving, scaling, and cropping of images. |
Celery | pip install celery |
A distributed task queue framework for processing asynchronous tasks and scheduled tasks |
Pygame | pip install pygame |
Library for developing 2D games |
openpyxl | pip install openpyxl |
Library for manipulating Excel files |
scikit-image | pip install scikit-image |
Libraries providing image processing and computer vision algorithms |
Flask-SQLAlchemy | pip install flask-sqlalchemy |
Integrated SQLAlchemy Flask extension, simplifying the use of databases in Flask |
Flask-WTF | pip install flask-wtf |
Provides functionality for using web forms in Flask |
PyMySQL | pip install pymysql |
Library for connecting to and manipulating MySQL databases |
SQLAlchemy-Utils | pip install sqlalchemy-utils |
SQLAlchemy's practical toolset provides some commonly used database operation tools |
Pygame Zero | pip install pgzero |
A framework for simplifying Pygame game development |
Flask-Login | pip install flask-login |
Provide user authentication and authorization functions for Flask applications |
Flask-Cors | pip install flask-cors |
Provide cross-domain resource sharing capabilities for Flask applications |
PyYAML | pip install pyyaml |
Library for parsing and generating YAML files |
The above are examples of some commonly used Python third-party libraries and tools. You can use the corresponding pip command to install them. Please note that the library names and installation commands in the examples may change over time, please refer to each library's official documentation for the latest installation information.
How to configure PIP
Configuring pip can be achieved by modifying the pip configuration file. On Windows systems, the pip configuration file is located in the %APPDATA%\pip\pip.ini
path, while on Linux and macOS systems, the configuration file is located in the ~/.pip/pip.conf
path.
Here are the steps on how to configure pip:
-
Open the pip configuration file (
%APPDATA%\pip\pip.ini
on Windows systems,~/.pip/pip.conf
on Linux and macOS systems). -
If the configuration file does not exist, you can manually create an empty file.
-
In the configuration file, you can add or modify the following configuration options:
[global]
: Global configuration option, applicable to all pip commands.[install]
: Installation related configuration options.[uninstall]
: Uninstall related configuration options.[list]
: Lists configuration options for installed packages.[search]
: Search package configuration options.[wheel]
: Configuration options for generating and installing binary wheel packages.[cache]
: Cache-related configuration options.[index]
: Configuration options related to package index.[global]
: Global configuration options.
-
In the configuration file, you can use the format
key = value
to set the value of the configuration option. For example:[global] trusted-host = pypi.org index-url = https://pypi.org/simple timeout = 10
In the above example,
trusted-host
is set topypi.org
to trust the host, andindex-url
is set to < a i=4> represents the index address of the packet, and is set to to represent the timeout period of 10 seconds.https://pypi.org/simple
timeout
10
-
Save the configuration file and close. When you rerun the pip command, the settings in the configuration file will be followed.
Please note that modifying pip's configuration files may require administrator rights or the use ofsudo
commands, depending on the operating system and permission settings of the location where the files are located.
In addition, you can also temporarily configure pip through command line parameters, such as using --trusted-host
, --index-url
and other parameters to specify the trusted host and package index address. .
The above are the general steps and examples for configuring pip. You can set the pip configuration options according to your own needs.