:py:mod:`doctor` ================ .. py:module:: conda.plugins.subcommands.doctor .. autoapi-nested-parse:: Implementation for `conda doctor` subcommand. Adds various environment and package checks to detect issues or possible environment corruption. .. toctree:: :hidden: :titlesonly: :maxdepth: 3 health_checks/index.rst Classes ------- .. autoapisummary:: conda.plugins.subcommands.doctor.PrefixData conda.plugins.subcommands.doctor.CondaSubcommand Functions --------- .. autoapisummary:: conda.plugins.subcommands.doctor.add_parser_help conda.plugins.subcommands.doctor.add_parser_prefix conda.plugins.subcommands.doctor.add_parser_verbose conda.plugins.subcommands.doctor.configure_parser conda.plugins.subcommands.doctor.execute conda.plugins.subcommands.doctor.conda_subcommands Attributes ---------- .. autoapisummary:: conda.plugins.subcommands.doctor.context conda.plugins.subcommands.doctor.hookimpl .. py:data:: context .. py:function:: add_parser_help(p: argparse.ArgumentParser) -> None So we can use consistent capitalization and periods in the help. You must use the add_help=False argument to ArgumentParser or add_parser to use this. Add this first to be consistent with the default argparse output. .. py:function:: add_parser_prefix(p: argparse.ArgumentParser, prefix_required: bool = False) -> argparse._MutuallyExclusiveGroup .. py:function:: add_parser_verbose(parser: argparse.ArgumentParser | argparse._ArgumentGroup) -> None .. py:class:: PrefixData(prefix_path: str | os.PathLike[str] | pathlib.Path, interoperability: bool | None = None) The PrefixData class aims to be the representation of the state of a conda environment on disk. The directory where the environment lives is called prefix. This class supports different types of tasks: - Reading and querying `conda-meta/*.json` files as `PrefixRecord` objects - Reading and writing environment-specific configuration (env vars, state file, nonadmin markers, etc) - Existence checks and validations of name, path, and magic files / markers - Exposing non-conda packages installed in prefix as `PrefixRecord`, via the plugin system .. py:property:: name :type: str Returns the name of the environment, if available. If the environment doesn't live in one the configured `envs_dirs`, an empty string is returned. The construct `prefix_data.name or prefix_data.prefix_path` can be helpful in those cases. .. py:property:: is_writable :type: bool | None | conda.auxlib._Null Check whether the configured path is writable. This is assessed by checking whether `conda-meta/history` is writable. It if is, it is assumed that the rest of the directory tree is writable too. Note: The value is cached in the instance. Use `.assert_writable()` for a non- cached check. .. py:property:: _pip_interop_enabled .. py:property:: _prefix_records :type: dict[str, conda.models.records.PrefixRecord] | None .. py:property:: _python_pkg_record :type: conda.models.records.PrefixRecord | None Return the prefix record for the package python. .. py:attribute:: _cache_ :type: dict[tuple[pathlib.Path, bool | None], PrefixData] .. py:method:: from_name(name: str, **kwargs) -> PrefixData :classmethod: Creates a PrefixData instance from an environment name. The name will be validated with `PrefixData.validate_name()` if it does not exist. :param name: The name of the environment. Must not contain path separators (/, \). :raises CondaValueError: If `name` contains a path separator. .. py:method:: from_context(validate: bool = False) -> PrefixData :classmethod: Creates a PrefixData instance from the path specified by `context.target_prefix`. The path and name will be validated with `PrefixData.validate_path()` and `PrefixData.validate_name()`, respectively, if `validate` is `True`. :param validate: Whether the path and name should be validated. Useful for environments about to be created. .. py:method:: __eq__(other: Any) -> bool Return self==value. .. py:method:: exists() -> bool Check whether the PrefixData path exists and is a directory. .. py:method:: is_environment() -> bool Check whether the PrefixData path is a valida conda environment. This is assessed by checking if `conda-meta/history` marker file exists. .. py:method:: is_frozen() -> bool Check whether the environment is marked as frozen, as per CEP 22. This is assessed by checking if `conda-meta/frozen` marker file exists. .. py:method:: is_base() -> bool Check whether the configured path refers to the `base` environment. .. py:method:: assert_exists() -> None Check whether the environment path exists. :raises EnvironmentLocationNotFound: If the check returns False. .. py:method:: assert_environment() -> None Check whether the environment path exists and is a valid conda environment. :raises DirectoryNotACondaEnvironmentError: If the check returns False. .. py:method:: assert_writable() -> None Check whether the environment path is a valid conda environment and is writable. :raises EnvironmentNotWritableError: If the check returns False. .. py:method:: assert_not_frozen() -> None Check whether the environment path is a valid conda environment and is not marked as frozen (as per CEP 22). :raises EnvironmentIsFrozenError: If the environment is marked as frozen. .. py:method:: validate_path(expand_path: bool = False) -> None Validate the path of the environment. It runs the following checks: - Make sure the path does not contain `:` or `;` (OS-dependent). - Disallow immediately nested environments (e.g. `$CONDA_ROOT` and `$CONDA_ROOT/my-env`). - Warn if there are spaces in the path. :param expand_path: Whether to process `~` and environment variables in the string. The expanded value will replace `.prefix_path`. :raises CondaValueError: If the environment contains `:`, `;`, or is nested. .. py:method:: validate_name(allow_base: bool = False) -> None Validate the name of the environment. :param allow_base: Whether to allow `base` as a valid name. :raises CondaValueError: If the name is protected, or if it contains disallowed characters (`/`, ` `, `:`, `#`). .. py:method:: load() -> None .. py:method:: reload() -> PrefixData .. py:method:: _get_json_fn(prefix_record: conda.models.records.PrefixRecord) -> str .. py:method:: insert(prefix_record: conda.models.records.PrefixRecord, remove_auth: bool = True) -> None .. py:method:: remove(package_name: str) -> None .. py:method:: get(package_name: str, default: T = NULL) -> conda.models.records.PackageRecord | T .. py:method:: iter_records() -> collections.abc.Iterable[conda.models.records.PrefixRecord] .. py:method:: iter_records_sorted() -> collections.abc.Iterable[conda.models.records.PrefixRecord] .. py:method:: all_subdir_urls() -> set[str] .. py:method:: query(package_ref_or_match_spec: conda.models.records.PackageRecord | conda.models.match_spec.MatchSpec | str) -> collections.abc.Iterable[conda.models.records.PrefixRecord] .. py:method:: _load_single_record(prefix_record_json_path: conda.common.path.PathType) -> None .. py:method:: _load_site_packages() -> dict[str, conda.models.records.PrefixRecord] .. py:method:: _get_environment_state_file() -> dict[str, dict[str, str]] .. py:method:: _write_environment_state_file(state: dict[str, dict[str, str]]) -> None .. py:method:: get_environment_env_vars() -> dict[str, str] | dict[bytes, bytes] .. py:method:: set_environment_env_vars(env_vars: dict[str, str]) -> dict[str, str] | None .. py:method:: unset_environment_env_vars(env_vars: dict[str, str]) -> dict[str, str] | None .. py:method:: set_nonadmin() -> None Creates $PREFIX/.nonadmin if sys.prefix/.nonadmin exists (on Windows). .. py:class:: CondaSubcommand Return type to use when defining a conda subcommand plugin hook. For details on how this is used, see :meth:`~conda.plugins.hookspec.CondaSpecs.conda_subcommands`. :param name: Subcommand name (e.g., ``conda my-subcommand-name``). :param summary: Subcommand summary, will be shown in ``conda --help``. :param action: Callable that will be run when the subcommand is invoked. :param configure_parser: Callable that will be run when the subcommand parser is initialized. .. py:attribute:: name :type: str .. py:attribute:: summary :type: str .. py:attribute:: action :type: Callable[[argparse.Namespace | tuple[str]], int | None] .. py:attribute:: configure_parser :type: Callable[[argparse.ArgumentParser], None] | None .. py:data:: hookimpl Decorator used to mark plugin hook implementations .. py:function:: configure_parser(parser: argparse.ArgumentParser) .. py:function:: execute(args: argparse.Namespace) -> None Run registered health_check plugins. .. py:function:: conda_subcommands()