#3614·pelican

Unclear error "CRITICAL AttributeError: 'NoneType' object has no attribute 'loader'" when the settings file does not exist.

Author: GullumluvlCreated Aug 15, 2026Updated Sep 13, 2026
Labelsbug
  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.
  • I can reproduce this problem with stock/default settings file, theme, and sample content (as described in above “How to Get Help” sections of the documentation).
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • Python version: 3.10.12
  • Pelican version: 4.11.0

Issue

Hi,

sorry this is a dumb error, but when you provide a wrong file name to pelican, you get this rather cryptic error message:

CRITICAL AttributeError: 'NoneType' object has no attribute 'loader'.

Steps to reproduce:

  1. Generate a dummy pelican project with pelican-quickstart
  2. Run pelican -vD -d -s filenamethatdontexist

In my case, I had given publishconf instead of publishconf.py.

Full debug logs

[18:44:51] DEBUG    Pelican version: 4.11.0.post0                                                                      __init__.py:644
           DEBUG    Python version: 3.10.21                                                                            __init__.py:645
           CRITICAL AttributeError: 'NoneType' object has no attribute 'loader'                                        __init__.py:683
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /usr/local/lib/python3.10/site-packages/pelican/__init__.py:648 in main                          │
│                                                                                                  │
│   645 │   logger.debug("Python version: %s", sys.version.split()[0])                             │
│   646 │                                                                                          │
│   647 │   try:                                                                                   │
│ ❱ 648 │   │   pelican, settings = get_instance(args)                                             │
│   649 │   │                                                                                      │
│   650 │   │   if args.autoreload and args.listen:                                                │
│   651 │   │   │   excqueue = multiprocessing.Queue()                                             │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/pelican/__init__.py:555 in get_instance                  │
│                                                                                                  │
│   552 │   │   config_file = DEFAULT_CONFIG_NAME                                                  │
│   553 │   │   args.settings = DEFAULT_CONFIG_NAME                                                │
│   554 │                                                                                          │
│ ❱ 555 │   settings = read_settings(config_file, override=get_config(args))                       │
│   556 │                                                                                          │
│   557 │   cls = settings["PELICAN_CLASS"]                                                        │
│   558 │   if isinstance(cls, str):                                                               │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/pelican/settings.py:192 in read_settings                 │
│                                                                                                  │
│   189 │   settings = override or {}                                                              │
│   190 │                                                                                          │
│   191 │   if path:                                                                               │
│ ❱ 192 │   │   settings = dict(get_settings_from_file(path), **settings)                          │
│   193 │                                                                                          │
│   194 │   if settings:                                                                           │
│   195 │   │   settings = handle_deprecated_settings(settings)                                    │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/pelican/settings.py:245 in get_settings_from_file        │
│                                                                                                  │
│   242 │   """Loads settings from a file path, returning a dict."""                               │
│   243 │                                                                                          │
│   244 │   name, ext = os.path.splitext(os.path.basename(path))                                   │
│ ❱ 245 │   module = load_source(name, path)                                                       │
│   246 │   return get_settings_from_module(module)                                                │
│   247                                                                                            │
│   248                                                                                            │
│                                                                                                  │
│ /usr/local/lib/python3.10/site-packages/pelican/settings.py:19 in load_source                    │
│                                                                                                  │
│    16                                                                                            │
│    17 def load_source(name: str, path: str) -> ModuleType:                                       │
│    18 │   spec = importlib.util.spec_from_file_location(name, path)                              │
│ ❱  19 │   mod = importlib.util.module_from_spec(spec)                                            │
│    20 │   sys.modules[name] = mod                                                                │
│    21 │   spec.loader.exec_module(mod)                                                           │
│    22 │   return mod                                                                             │
│ in module_from_spec:568                                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'loader'

Expected result

Pelican should fail with an error message like settings file not found.