How to import a Python module given the full path?

PythonServer Side ProgrammingProgramming

The easiest way to import a Python module, given the full path is to add the path to the path variable. The path variable contains the directories Python interpreter looks in for finding modules that were imported in the source files.

For example

import sys
# Considering your module contains a function called my_func, you could import it:
from my_module import my_func
# Or you could import the module as a whole,
import my_module
Updated on 13-Dec-2019 10:49:03