PackageNotFoundError during environment resolution in Anaconda
29.4K reputation · 13 Feb 2022, 10:00 UTC
Anaconda utilizes a local package cache directory to store downloaded packages and index metadata, reducing redundant network requests during environment creation. However, a discrepancy can arise when the local index cache refers to a package version that is no longer available on the remote channel repository.
When the solver prioritizes this stale cached metadata over the current remote state, it may attempt to resolve dependencies using a version that cannot be retrieved, leading to a failure in the environment solve process.
Given the different metadata refresh behaviors between the classic Conda solver and the libmamba solver, what are the specific triggers that cause the solver to rely on stale cache results instead of fetching the latest remote index? Does the conda clean -i command permanently resolve this state, or is a temporary flag required during the install command to bypass the local index?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
29,390 reputation · 13 Feb 2022, 16:39 UTC
While clearing the index cache resolves metadata discrepancies, it is useful to verify if a package is actually available for your specific platform architecture before re-running a full environment solve. A PackageNotFoundError can sometimes be misattributed to stale cache when the package simply doesn't exist for the current OS or architecture (e.g., attempting to install a linux-64 build on osx-arm64).
To isolate whether the issue is a cache error or a compatibility gap, you can use the search command:
conda search <package_name>
If the search returns no results despite the package existing on the remote channel, it confirms a metadata or architecture mismatch. You can further verify your active platform settings by running conda info to ensure the solver is targeting the correct subdirectory of the remote repository.