Learn Python Pip Quick Guide

Updated: Sep 5

Pip is the package installer for Python. We can use pip to install packages that are not distributed as part of the standard library from the Python Package Index and other indexes.

How To Use Python Pip
How To Use Python Pip
  • How to install Pip on Linux?

  • How to install & remove a python package with Pip

  • Install a python package with a specific version

  • Install a python package from a specific repo

How to install Pip on Linux?

  • First, we need to download pip installer - wget https://bootstrap.pypa.io/get-pip.py or curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

  • second, we need to run the following command in the folder where you have downloaded get-pip.py. python get-pip.py

If some certificate issue comes then use: wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate

Go to download dir and run the command: python get-pip.py

Install a package from PyPI (default python index)

  • $ pip install SomePackage Successfully installed SomePackage

Show what files were installed

  • $ pip show --files SomePackage Name: SomePackage Version: 1.0 Location: /my/env/lib/pythonx.x/site-packages Files: ../somepackage/__init__.py [...]

List what packages are outdated

  • $ pip list --outdated SomePackage (Current: 1.0 Latest: 2.0)

Upgrade a package

  • $ pip install --upgrade SomePackage [...] Found existing installation: SomePackage 1.0

Uninstall a package

  • $ pip uninstall SomePackage Uninstalling SomePackage: /my/env/lib/pythonx.x/site-packages/somepackage Proceed (y/n)? y Successfully uninstalled SomePackage

Install a python packeage with specific version

  • $ pip install SomePackage # latest version

  • $ pip install SomePackage==1.0.4 # specific version

  • $ pip install SomePackage>=1.0.4' # minimum version

Install a python package from a specific repo

Install from specific repo

  • $ pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

  • -i, --index-url <url> default is (https://pypi.python.org/simple). This should point to a repository

Linux Troubleshooting Guide:

Linux Learning Guide: