I am trying to build the python api for an open source project called Zulip and I keep running into the same issue as indicated by the screenshot below.
My solution is to check the version number of pip and use the import the correct main function correctly
import pip
if int(pip.__version__.split('.')[0])>9:
from pip._internal import main
else:
from pip import main
def install(package):
main(['install', package])