Last active
October 3, 2016 06:20
-
-
Save qizhihere/1e8772b9149c434abfe221234740c3f6 to your computer and use it in GitHub Desktop.
Python helper functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def has_pkg(package): | |
import importlib | |
try: | |
importlib.import_module(package) | |
except ImportError: | |
return False | |
return True | |
def pip_install(package): | |
import pip | |
pip.main(['install', package]) | |
def ensure_pkg(package): | |
has_pkg(package) or pip_install(package) | |
# ensure_pkg('pyftpdlib') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment