Skip to content

Instantly share code, notes, and snippets.

@pm-hwks
Created October 23, 2017 23:19
Show Gist options
  • Save pm-hwks/b092b6ebf389b9bae8e4248875fda0b1 to your computer and use it in GitHub Desktop.
Save pm-hwks/b092b6ebf389b9bae8e4248875fda0b1 to your computer and use it in GitHub Desktop.
[Install pip packages using code] use this script to install python packages using nothin but python code and also list installed packages #python #pip #packages #install
# Install requests package and list packages
import pip
# install request package using pip
pip.main(['install', 'requests'])
# List installed packges
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
import requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment