The problem:

I've created two scripts in blender (importTest and loggingConfig), as shown in the following picture:

Modules example

But when I try to import loggingConfig I obtain the error

ModuleNotFoundError: No module named 'loggingConfig'

Options tried:

importTest (Try #1):

import loggingConfig

importTest (Try #2):

import bpy
import sys

dir = bpy.data.filepath
if not dir in sys.path:

import loggingConfig

In both cases obtaining the error above


1 Answer 1


For blender below 2.8

The script to be imported must have the '.py' suffix (e.g. loggingConfig.py), it can be imported as follows:

import loggingConfig

If loggingConfig suffered any changes, you must reloaded, like this:

import loggingConfig

# The following lines reload the module in each run
import imp

This can be ran each time to ensure to have always the most up to date version of loggingConfig.py.

For blender >= 2.8

The script to be imported does not need to have the '.py' suffix (e.g. loggingConfig), it can be imported the following:

import bpy

loggingConfig = bpy.data.texts["loggingConfig"].as_module()

In this case it isn't necessary to reload the script in each run.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .