pip command not working in cmd code example

Example 1: python pip not working

Correct command:
python -m pip install modulename
Alternative(if it doesn't work):
py.exe -m pip install modulename

Example 2: 'pip' is not recognized as an internal or external command, operable program or batch file.

py -m pip install [packagename]

Example 3: add pip to path

import os
import sys
pipPath = f'{os.path.dirname(sys.executable)}\\Scripts'
os.system(f'setx PATH "%PATH%;{pipPath}"')

Example 4: pip not working in command prompt

Make sure pip is added to the PATH variable