GEOG 489
Advanced Python Programming for GIS

(link is external) (link is external)

3.2.1 Conda Environment Troubleshooting

PrintPrint

The conda-libmamba-solver(link is external) is an alternative dependency solver for the Conda package manager that uses the libmamba library, designed to resolve package dependencies more efficiently and quickly than the default Conda solver. There is a good comparison to the classic solver documented here(link is external) if you want to compare the two. You can check your environment by using the conda info command.

The libmamba solver is particularly useful when dealing with complex environments that involve many dependencies, as it can reduce environment creation time by using advanced optimization techniques. conda-libmamba-solver is distributed as a separate package, available on both conda-forge and defaults. The plugin needs to be present in the same environment you use conda from and according to the mamba documentation page, ships with conda and should be in your base environment. If it is not already installed, you can install it with your base environment activated, run this command:

conda install -n base conda-libmamba-solver

Once you’ve installed the conda-libmamba-solver, you can explicitly tell Conda to use it for environment creation and package installation by passing the --solver option with the value libmamba. Here are a few steps to create an environment using conda-libmamba-solver:

conda create --name ACP3 python=3.11 arcgis=2.3.1 numpy pandas --solver=libmamba

Or with using the yaml in the same format as we tried before:

conda create --name ACP3 -f "c:\path to\ACP3.yaml" --solver=libmamba

You'll also notice that the logging is more robust and informative to why the combination of packages may not have resolved instead of just saying "Solving Failed" with no context. You can use this information to change package versions to find a working combination. The less specific package versions you can work with, the more likelihood the environment will resolve. Sometimes it's beneficial to only set the main packages versions and let the solver figure out the rest.

If you prefer the conda-libmamba-solver solver to the conda solver, you can update the conda environment to use the conda-libmamba-solver by default. To do this, refer to the documentation on conda-libmamba-solver(link is external)

Conda Clean

Note! Always make sure to use conda clean cautiously, as it might remove files that are needed. Review the command's output carefully to ensure it's not deleting anything important. If you're unsure, it's a good idea to ask for help or research more about the specific files it's deleting.

conda clean is a command provided by the conda package manager that helps maintain your environment by freeing up space. It removes unnecessary files and caches that could take up disk space in your conda environment. The command includes functionality to clean specific types of files:

  • conda clean --packages: Removes unused packages
  • conda clean --tarballs: Removes .tar files which have been extracted and are no longer needed
  • conda clean --index-cache: Removes index cache which tends to speed up package lookup but can potentially become very large
  • conda clean --source-cache: Removes source cache files. These files are generally required for building packages, once a package is built they are not used.
  • conda clean --all: Combines all of the above.

If a conda environment install fails, there may be corrupted or incorrect packages left in the package cache. These can prevent you from creating new conda environments, or make your existing ones behave erratically. conda clean --packages can help by removing these unused packages; this will force conda to re-download them the next time it needs those packages. For instance, you may have an incomplete package that was downloaded due to a network error. The command conda clean --packages will remove the incomplete package from cache. The next time you try to create the environment, conda will attempt to download the package again, this time hopefully without any network issues.

Map fails to display - widgetsnbextension

If the map did not display with the test Notebook, (in the browser - not your IDE) we need to check if the environment contains a compatible widgetsnbextension version. In the Python Command window with the AC311_NBK environment activated, execute a conda list and verify that the widgetsnbextension has 'esri' and not 'conda-forge' or 'default'.

arcgis               2.4.0.1   py311_103   esri
arcgis-mapping       4.30.0    py_305      esri
    ...
widgetsnbextension   4.0.13    py_0        esri

If this channel is different, we need to uninstall widgetsnbextension and explicitly install from the esri channel by executing conda remove widgetsnbextension, and conda install -c esri widgetsnbextension. This may uninstall, update, and install other packages, which is ok. Once this is resolved, try the sample again. If this fails, let your instructor know.