How to import a Python module by the absolute path

Modules used in Blender scripts and add-ons are located in the same directory as the script or add-on, or in the Blender installation directory by the “blender_version\python\lib\” path. However, it is possible to load a module located elsewhere on the hard drive.

To do this, we need to load the module by its absolute path.

Let’s define with variables the full path to the module directory and the name under which the module will be loaded to the API:

Next, load the module using the “importlib”:

Now we can use the loaded module in the usual way by its name.

5 3 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments