Skip to content

Instantly share code, notes, and snippets.

@rustoceans
Created October 14, 2017 09:54
Show Gist options
  • Save rustoceans/5ab0f3bf718e9282ae09f981fc963cd8 to your computer and use it in GitHub Desktop.
Save rustoceans/5ab0f3bf718e9282ae09f981fc963cd8 to your computer and use it in GitHub Desktop.
def install_and_import(package):
import importlib
try:
importlib.import_module(package)
except ImportError:
import pip
pip.main(['install', package])
finally:
globals()[package] = importlib.import_module(package)
install_and_import('transliterate')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment