pip install in python script code example

Example 1: installing pip

python -m pip install --upgrade pip

Example 2: python install module from script

import subprocess
import sys

def install(package):
    subprocess.check_call([sys.executable, "-m", "pip", "install", package])

Example 3: python pip install

## To install Pip, first download get-pip.py from:
https://bootstrap.pypa.io/get-pip.py
  
## Then run the following command in the command line
## in the folder where the file has been saved.
python get-pip.py

Example 4: install pip in python

python get-pip.py

Tags:

Misc Example