Import python modules in the background in REPL
Some python modules, notably matplotlib , take a long time to load start = datetime.datetime.now(); import numpy, pandas, matplotlib, sklearn; datetime.datetime.now() - start takes half a second with cached files, and several seconds for non-cached files . Is there a way to load these modules in the background, when in the Python interpreter? You can import modules in separate threads. Here is the solution. Create a file load_modules.py : from concurrent.futures import ThreadPoolExecutor import importlib import sys modules_to_load = ['numpy', 'pandas', 'matplotlib'] def do_import(module_name):