I need to install a package from PyPi straight within my script. Maybe there\'s some module or distutils (distribute, pip etc.) featur
distutils
distribute
pip
i added some exception handling to @Aaron's answer.
import subprocess import sys try: import pandas as pd except ImportError: subprocess.check_call([sys.executable, "-m", "pip", "install", 'pandas']) finally: import pandas as pd