Install required dependencies at runtime
xxxxxxxxxx
# This will fail
def uno():
return json.dumps({"a": 1, "b": 2})
try:
uno()
except NameError as ne:
print("Error:", ne)
xxxxxxxxxx
# This will not fail
import requires # Module is callable! (checkout funkify for more info -- `pip install funkify`)
@requires('json')
def uno():
return json.dumps({'a': 1, 'b': 2})
uno()