Skip to content

doesn't easily load_extension() or %load_ext from ~/.ipython/extensions/ #14263

@blubberdiblub

Description

@blubberdiblub

I've got a custom extension in ~/.ipython/extensions/ (the path reflected in get_ipython().extension_manager.ipython_extension_dir by default).

I expect all extensions in there to load simply with a %load_ext name or get_ipython().extension_manager.load_extension('name').

However, they aren't found. I have to resort to own ugly sys.path manipulation to get them to load.

I tracked it down to IPython/core/extensions.py where ExtensionManager._load_extension() prepares for searching in the extensions dir by importing prepended_to_syspath, but fails to actually make use of that.

Note that ExtensionManager.reload_extension() imports and makes use of prepended_to_syspath, giving me a strong feeling that it missing from _load_extension() is just an oversight.

{'commit_hash': '49914f938',
 'commit_source': 'installation',
 'default_encoding': 'utf-8',
 'ipython_path': '/home/nboehm/venv3.12/lib/python3.12/site-packages/IPython',
 'ipython_version': '8.18.1',
 'os_name': 'posix',
 'platform': 'Linux-6.5.0-14-lowlatency-x86_64-with-glibc2.38',
 'sys_executable': '/home/nboehm/venv3.12/bin/python3.12',
 'sys_platform': 'linux',
 'sys_version': '3.12.0 (main, Oct  4 2023, 06:27:34) [GCC 13.2.0]'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions