Search code examples
pythoncondapymc3netcdf4

Cannot Load netCDF4 Due to Missing .dll File


I recently installed pymc3 via conda install on my Windows 10 machine, but it throws up an ImportError whenever I try to import it. The exact error message, linked specifically to the netCDF4 package, provided is:

File "C:\Users\benam\anaconda3\lib\site-packages\netCDF4\__init__.py", line 3, in <module>
from ._netCDF4 import * ImportError: DLL load failed while importing _netCDF4: The specified procedure could not be found.

I have found next to nothing online that pertains to this exact problem, with the exception of this thread: https://github.com/ContinuumIO/anaconda-issues/issues/1671

Here, two users discovered that this error was due to a missing debug dll file from the MSVC 2010 C++ runtime library; because this debug dll file is not present on all systems, this issue would arise from time to time.

Although I sincerely hope this is no longer the issue that contributes to this error (since this was a pretty major bug and the linked thread is nearly 3 years old), I tried downloading that specific debug dll (msvcr100d.dll) and placing it in the same location as the non-debug version on my system, with no success (the same error message persisted).

I have also tried another trick that apparently used to work from that same thread, where I removed pymc3 via conda, then reinstalled it using pip instead. This did not work, either. I tried the same for the netCDF4 module specifically, as well, since this is the one that's causing the problem, but that also did not work. When running pip list or conda list (depending on which method I used to install netCDF4 and/or pymc3), these modules appeared with their version numbers, so they seem to be installed properly. I've also tried a fresh install of anaconda, and even a fresh install of python by itself, where I installed all necessary packages via pip; neither of these actions worked, and I would always end up with the same error message.

At this point, I'm at a complete loss as to what I can do to resolve this issue. Is there any new information on this, or at least, newer than the ~3 year old thread I've linked?

Any help is greatly appreciated!


Solution

  • I had the same problem, although I followed this guide for installing PyMC3 on my Windows 10 machine: https://github.com/pymc-devs/pymc3/wiki/Installation-Guide-(Windows).

    However I followed initially the pure conda installation. It worked for me doing a mixed installation through conda and pip:

    # starting out with a fresh environment
    conda create -n mypm3env python=3.8 mkl-service libpython m2w64-toolchain scipy matplotlib pandas
    # install PyMC3 through pip
    pip install pymc3