Skip to content
Advertisement

ImportError: DLL load failed, while file is in working directory

I’m trying to import scanpy for use in jupyter notebook with miniconda3. However, when I try to import scanpy, it gives an ImportError about the hdf5extension dll. When I look in the directory of the package tables though, I can see two files named hdf5.dll and hdf5extension.cp37-win_amd64.pyd (https://gyazo.com/a7d5a9d7d28756a8d82bc060b33b91ca). I assume that these are the files which should be imported, but I don’t understand what’s going wrong with the import.

I’ve used scanpy before on this system, but problems started showing up after I installed h5py via conda (not knowing that h5py is automatically included if you install scanpy via conda). So first I uninstalled h5py, which didn’t work. Uninstalled and reinstalled miniconda3 twice, which did not work either. Setting the $PATH variable manually didn’t help either.

So then I looked into the file.py which is referred to in the traceback, and figured that there should be a file in the tables directory. I found the files, and thought that maybe they were named wrongly, so I tried changing the name, which did not work either. Downgrading python from 3.7.1 to 3.6.6 didn’t work, nor creating a new env in conda with python 3.6.6 and installing all the required packages.

Working on Windows 7 64-bit, with conda 4.5.12 with the miniconda3 installer.

> Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v
.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

> import scanpy

> Traceback (most recent call last):

> File "", line 1, in File "C:Miniconda3envspy36libsite-packagesscanpy__init__.py", line 11, in 

> from . import tools as tl

> File "C:Miniconda3envspy36libsite-packagesscanpytools__init__.py", line 12, in <module>

> from .sim import sim

> File "C:Miniconda3envspy36libsite-packagesscanpytoolssim.py", line 19, in <module>

> from .. import readwrite

> File "C:Miniconda3envspy36libsite-packagesscanpyreadwrite.py", line 9,
in <module>

> import tables

> File "C:Miniconda3envspy36libsite-packagestables__init__.py", line 131, in <module>

> from .file import File, open_file, copy_file

> File "C:Miniconda3envspy36libsite-packagestablesfile.py", line 35, in <module>

> from . import hdf5extension

> ImportError: DLL load failed: The specified procedure could not be found.

Advertisement

Answer

I had the very same problem you had, twice.

This seemed to be a Windows-specific problem. My first solution was to update my Visual Studio Version which comes with C-Build Tools that might be required to run scanpy in some way(?). This worked fine for some time.

A few weeks later I had the same ImportError again. This time the only thing that helped was to use an old version of h5py (2.8). Setting up a new Virtual Environment or resetting the Miniconda packages did not help, neither did specifying the hdf5-DLL save location as a windows variable.

My suggestion is that the new hdf5 libraries in h5py Version 2.9 are not yet compatible with the current C-Compilers from Microsoft VS.

Hope this helps!

Advertisement