Registry / devops / magicalimport

magicalimport

JSON →
library0.9.2pypypi✓ verified 80d ago

A utility to import a Python module by its physical file path, bypassing the normal sys.path resolution. Version 0.9.2, requires Python >=3.10. Maintenance mode; no recent releases.

pip install magicalimport
INSTALL
IMPORT
SIG · MAGICALIMPORT
M
magicalimport
devopspythonv0.9.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

import_from_physical_path
from magicalimport import import_from_physical_path
from magicalimport import import_from_path

Import a module by its file path.

import os from magicalimport import import_from_path # Create a temporary module file with open('temp_module.py', 'w') as f: f.write('def foo(): return "hello"') mod = import_from_path('./temp_module.py') print(mod.foo()) # 'hello' # Clean up os.remove('temp_module.py')
Debug
Known issues
gotchaThe module is cached using the file path as key. If the file content changes, re-importing may return the old cached module.
fix
Use importlib.reload() or clear sys.modules manually.
affects: all
gotchaDoes not handle relative paths with '../' correctly on all platforms. Use os.path.abspath() to normalize.
fix
Pass an absolute path using os.path.abspath().
affects: all
deprecatedPython's importlib.util.spec_from_file_location() and importlib.util.module_from_spec() are now the standard way to import by path. This library may become obsolete.
fix
Consider using importlib instead.
affects: all
Upgrade
Version history
0.9.2latest on PyPI · released Jul 21, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
magicalimport — pip install magicalimport · libregistry