Sometimes conda will claim that a package is already installed, but you do not see the package in your
Example: a Python package that gives
There are several possible causes and solutions for this issue.
You are not in the same environment as your package:
conda info tells you what conda environment is currently active underdefault environment.
Verify that you are using Python from the correct environment:
You may have set the
PYTHONHOME variable forPython packages:
The command conda info -a will show you the values of the environment variables. These environment variables cause Python to load files from locations other than the standard ones.
conda works best when these environment variables are not set, as their typical use-cases are obviated by conda environments, and a common issue is that they will cause Python to pick up the wrong versions or broken versions of a library.
To unset them temporarily for the current terminal session, run:
To unset them permanently:
- Check for
PYTHONPATHin the files
~/.bashrc,~/.bash_profile, ~/.profile if you use
~/.zshrcif you use
- Or the file output by PROFILE if you use PowerShell on Windows.
Python packages may have any site-specific directories:
site-specific files typically live in
~/.local on Unix. As with
PYTHONPATH, Python may try importing packages from this directory, which can cause issues. It is recommended to remove the
The environment variables LD_LIBRARY_PATH on Linux andDYLD_LIBRARY_PATH on macOS are set for C libraries:
The environment variables act similarly to
PYTHONPATH for Python.
If they are set, they can cause libraries to be loaded from locations other than the conda environment. Again, conda environments obviate most use-cases for these variables, so it is recommended to unset them if they are set.
To see if they are set, run:
conda info -a
To unset DYLD_LIBRARY_PATH on macOS:
To unset LD_LIBRARY_PATH on Linux:
Occasionally, an installed package will become corrupted:
conda works by unpacking the packages in the
pkgs directory and then hard linking them to the environment. Sometimes these get corrupted somehow, breaking all environments that use them, and also any additional environments, since the same files are hard linked each time.
conda install -f, force install will unarchive the package again and re-link it. It also does a md5 verification on the package if this is different, it’s because your channels have changed and there is a different package with the same name, version, and build number.
NOTE: This breaks the links to any other environments that already had this package installed, so you’ll have to reinstall it there too.
It also means that running
conda install -f many times can take more disk space if you have many environments.
--no-deps, soconda install -f packagename will not reinstall any of the dependencies of the package.