{"record":{"id":"91c9b02b0ab3d24b","repo":"hankcs/HanLP","slug":"some-modules-e-name-etc-required-by-this-mode","errorCode":null,"errorMessage":"Some modules ({e.name} etc.) required by this model are missing. Please install the full version:\n\n\tpip install hanlp[full] -U","messagePattern":"Some modules \\((.+?) etc\\.\\) required by this model are missing\\. Please install the full version:\n\n\tpip install hanlp\\[full\\] -U","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"hanlp/utils/component_util.py","lineNumber":115,"sourceCode":"    assert cls, f'{meta_filename} doesn\\'t contain classpath field'\n    try:\n        obj: Component = object_from_classpath(cls)\n        if hasattr(obj, 'load'):\n            if transform_only:\n                # noinspection PyUnresolvedReferences\n                obj.load_transform(save_dir)\n            else:\n                if os.path.isfile(os.path.join(save_dir, 'config.json')):\n                    obj.load(save_dir, verbose=verbose, **kwargs)\n                else:\n                    obj.load(metapath, **kwargs)\n            obj.config['load_path'] = load_path\n        return obj\n    except ModuleNotFoundError as e:\n        if isdebugging():\n            raise e from None\n        else:\n            raise ModuleNotFoundError(\n                f'Some modules ({e.name} etc.) required by this model are missing. Please install the full version:'\n                '\\n\\n\\tpip install hanlp[full] -U') from None\n    except ValueError as e:\n        if e.args and isinstance(e.args[0], str) and 'Internet connection' in e.args[0]:\n            raise ConnectionError(\n                'Hugging Face 🤗 Transformers failed to download because your Internet connection is either off or bad.\\n'\n                'See https://hanlp.hankcs.com/docs/install.html#server-without-internet for solutions.') \\\n                from None\n        raise e from None\n    except Exception as e:\n        # Some users often install an incompatible tf and put the blame on HanLP. Teach them the basics.\n        try:\n            you_installed_wrong_versions, extras = check_version_conflicts(extras=('full',) if tf_model else None)\n        except Exception as check_e:\n            you_installed_wrong_versions, extras = None, None\n        if you_installed_wrong_versions:\n            raise version.NotCompatible(you_installed_wrong_versions + '\\nPlease reinstall HanLP in the proper way:' +\n                                        '\\n\\n\\tpip install --upgrade hanlp' + (","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/utils/component_util.py#L97-L133","documentation":"While loading a model, one of its imports (transformers, a TF backend, an optional tokenizer, etc.) raised ModuleNotFoundError. Rather than surfacing the raw import error, HanLP tells you the minimal install is missing optional dependencies and suggests pip install hanlp[full] -U. When debugging is enabled the original error is re-raised unchanged.","triggerScenarios":"Calling hanlp.load() on a transformer-backed or TF model with only the base hanlp package installed; e.name in the message tells you exactly which module is missing.","commonSituations":"Installing plain 'pip install hanlp' instead of hanlp[full]; stripped-down Docker images; upgrading hanlp but not its extras; mixing pip/conda envs so a dependency silently disappears.","solutions":["Run pip install 'hanlp[full]' -U (quote the extras in zsh).","If you want a lean install, install just the missing module named in the message (e.g. pip install transformers) — but [full] is the supported combination.","Set a debug flag (HANLP_DEBUG/isdebugging) if you need the original traceback to find which import failed."],"exampleFix":"# before\npip install hanlp\n# after\npip install 'hanlp[full]' -U","handlingStrategy":"try-catch","validationCode":"try:\n    import transformers  # or the module your model needs\nexcept ModuleNotFoundError:\n    raise SystemExit('pip install \"hanlp[full]\" -U')","typeGuard":null,"tryCatchPattern":"try:\n    model = hanlp.load(mid)\nexcept ModuleNotFoundError as e:\n    if 'hanlp[full]' in str(e):\n        subprocess.run([sys.executable, '-m', 'pip', 'install', 'hanlp[full]', '-U'])\n        model = hanlp.load(mid)\n    else:\n        raise","preventionTips":["Install hanlp[full] up front in Dockerfiles and requirements.txt.","Pin the extras in your dependency manifest so lean installs cannot ship."],"tags":["installation","missing-dependency","python"],"backgroundTag":"missing-optional-dependency","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}