There are two ways to install pip in Python: "Use the get-pip.py script" and "Use the operating system's package manager": 1. Open a browser and download the "get-pip.py" script file, open a command line terminal and navigate to the directory where the file is located, run the "python get-pip.py" command; 2. If you are using a Linux or macOS system, try using the operating system's package manager to install pip.
# Operating system for this tutorial: Windows 10 system, Dell G3 computer.
When installing Python, pip (Python package management tool) should have been included by default. You can use the following command to check whether pip has been installed:
pip --version
If the output is similar to pip x.x.x, it means that pip has been installed successfully.
If you do not have pip installed, you can try to install it using one of the following methods:
Method 1: Use the get-pip.py script
Open a browser and visit https://bootstrap.pypa.io/get-pip.py to download the get-pip.py script file.
Open a command line terminal (Command Prompt or PowerShell for Windows, Terminal for Mac).
Navigate to the directory where the get-pip.py file is located on the command line.
Run the following command to install pip:
python get-pip.py
Method 2: Use the operating system’s package manager
If you are using a Linux or macOS system, you can try to use the operating system's package manager to install pip.
sudo apt-get install python3-pip
sudo dnf install python3-pip
sudo easy_install pip
Please note that on some Linux distributions and macOS, the command may not work properly. It may vary depending on the system version or other factors. You can adapt the command to your system and package manager.
No matter which installation method you choose, once the installation is complete, you can use the pip command on the command line to install Python packages. For example, use the following command to install the numpy package:
pip install numpy
Hope this helps! If you have any other questions, please feel free to ask.
The above is the detailed content of python installation pip command. For more information, please follow other related articles on the PHP Chinese website!