doctor
#
Implementation for conda doctor subcommand. Adds various environment and package checks to detect issues or possible environment corruption.
Classes#
The PrefixData class aims to be the representation of the state |
|
Return type to use when defining a conda subcommand plugin hook. |
Functions#
|
So we can use consistent capitalization and periods in the help. You must |
|
|
|
|
|
|
|
Run registered health_check plugins. |
Attributes#
- context#
- 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.
- add_parser_prefix(p: argparse.ArgumentParser, prefix_required: bool = False) argparse._MutuallyExclusiveGroup #
- add_parser_verbose(parser: argparse.ArgumentParser | argparse._ArgumentGroup) None #
- 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
- property name: 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.
- property is_writable: 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.
- property _pip_interop_enabled#
- property _prefix_records: dict[str, conda.models.records.PrefixRecord] | None#
- property _python_pkg_record: conda.models.records.PrefixRecord | None#
Return the prefix record for the package python.
- _cache_: dict[tuple[pathlib.Path, bool | None], PrefixData]#
- classmethod from_name(name: str, **kwargs) PrefixData #
Creates a PrefixData instance from an environment name.
The name will be validated with PrefixData.validate_name() if it does not exist.
- Parameters:
name -- The name of the environment. Must not contain path separators (/, ).
- Raises:
CondaValueError -- If name contains a path separator.
- classmethod from_context(validate: bool = False) PrefixData #
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.
- Parameters:
validate -- Whether the path and name should be validated. Useful for environments about to be created.
- 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.
- 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.
- assert_exists() None #
Check whether the environment path exists.
- Raises:
EnvironmentLocationNotFound -- If the check returns False.
- assert_environment() None #
Check whether the environment path exists and is a valid conda environment.
- Raises:
DirectoryNotACondaEnvironmentError -- If the check returns False.
- assert_writable() None #
Check whether the environment path is a valid conda environment and is writable.
- Raises:
EnvironmentNotWritableError -- If the check returns False.
- 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.
- 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.
- Parameters:
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.
- validate_name(allow_base: bool = False) None #
Validate the name of the environment.
- Parameters:
allow_base -- Whether to allow base as a valid name.
- Raises:
CondaValueError -- If the name is protected, or if it contains disallowed characters (/, ` , `:, #).
- reload() PrefixData #
- _get_json_fn(prefix_record: conda.models.records.PrefixRecord) str #
- insert(prefix_record: conda.models.records.PrefixRecord, remove_auth: bool = True) None #
- get(package_name: str, default: T = NULL) conda.models.records.PackageRecord | T #
- iter_records() collections.abc.Iterable[conda.models.records.PrefixRecord] #
- iter_records_sorted() collections.abc.Iterable[conda.models.records.PrefixRecord] #
- query(package_ref_or_match_spec: conda.models.records.PackageRecord | conda.models.match_spec.MatchSpec | str) collections.abc.Iterable[conda.models.records.PrefixRecord] #
- _load_site_packages() dict[str, conda.models.records.PrefixRecord] #
- class CondaSubcommand#
Return type to use when defining a conda subcommand plugin hook.
For details on how this is used, see
conda_subcommands()
.- Parameters:
name -- Subcommand name (e.g.,
conda my-subcommand-name
).summary -- Subcommand summary, will be shown in
conda --help
.action -- Callable that will be run when the subcommand is invoked.
configure_parser -- Callable that will be run when the subcommand parser is initialized.
- configure_parser: Callable[[argparse.ArgumentParser], None] | None#
- hookimpl#
Decorator used to mark plugin hook implementations
- configure_parser(parser: argparse.ArgumentParser)#
- execute(args: argparse.Namespace) None #
Run registered health_check plugins.
- conda_subcommands()#