Python3 pip
pip is a Python package management tool that provides functions for finding, downloading, installing, and uninstalling Python packages.
Packages can also be found at https://pypi.org/.
The latest Python versions come with pip pre-installed.
Note: Python 2.7.9+ or Python 3.4+ and above come with pip built-in.
If not installed, refer to: Python pip Installation and Usage.
To check if pip is already installed, use the following command:
To download and install a package, use the following command:
For example, to install the numpy package:
You can also easily remove a package with the following command:
For example, to remove the numpy package:
To view the packages you have installed, use the following command:
Exporting the Current Python Environment Configuration
Section titled “Exporting the Current Python Environment Configuration”To export the configuration of the current Python environment, you can use the pip freeze command.
The pip freeze command lists all Python packages installed in the current environment along with their version information. You can save it to a file, such as requirements.txt, as shown below:
The above command will create a file named requirements.txt in the current directory, containing all installed packages and their version information.
Then, you can use this file elsewhere to recreate the same environment by running the following command:
The above command will reinstall all required packages based on the packages and version information listed in requirements.txt, thereby recreating the same environment.
Extended Content
Section titled “Extended Content”Introduction to Anaconda
Section titled “Introduction to Anaconda”The Anaconda distribution includes Python.
Anaconda is an integrated data science and machine learning environment that includes the Python interpreter as well as a large number of commonly used data science libraries and tools.
The package, dependency, and environment management tool for Anaconda is the conda command. Compared to the traditional Python pip tool, Anaconda’s conda makes it easier to switch between different environments, and environment management is relatively simple.
For detailed Anaconda installation and introduction, refer to: Anaconda Tutorial.