HarryMuesli
HarryMuesli

Reputation: 43

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:\Miniconda3\envs\py36\lib\site-packages\scanpy\__init__.py", line 11, in 

> from . import tools as tl

> File "C:\Miniconda3\envs\py36\lib\site-packages\scanpy\tools\__init__.py", line 12, in <module>

> from .sim import sim

> File "C:\Miniconda3\envs\py36\lib\site-packages\scanpy\tools\sim.py", line 19, in <module>

> from .. import readwrite

> File "C:\Miniconda3\envs\py36\lib\site-packages\scanpy\readwrite.py", line 9,
in <module>

> import tables

> File "C:\Miniconda3\envs\py36\lib\site-packages\tables\__init__.py", line 131, in <module>

> from .file import File, open_file, copy_file

> File "C:\Miniconda3\envs\py36\lib\site-packages\tables\file.py", line 35, in <module>

> from . import hdf5extension

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

Upvotes: 4

Views: 5432

Answers (3)

sevsea
sevsea

Reputation: 33

I met a similar problem, and I spend half a day on it. To the point, the problem occured in the tables package, and so it is, at least for me.

The tables package was broken. I uninstalled it via conda and delete residual dirs(necessary, all dirs named after tables; the path can be got from the err info) Then I reinstall it via 'pip', because my 'conda' channels don't have it.

An interesting thing is that 'pip' warmed me my h5py(2.8.0) is outdate and recommend me to update it to 2.10.0 for scanpy. (In fact, scanpy could work well then)

If you do so, congratulation, the tables broke again. It seems that the h5py(2.10.0) would also install tables(but it has errors in win10) Besides, if you get ImportError: DLL load failed for h5py, you should also use a similar pipe to reinstall it(delete manually).

Anyway, scanpy works in win10 scanpy==1.7.1 h5py==2.8.0 tables==3.4.4. Maybe h5py 2.10.0 can also work if you reinstall tables at last.

Upvotes: 1

user505794
user505794

Reputation: 1

I have the same trouble with scanpy, I uninstalled the anaconda several times my problem is as follows:

>>> import scanpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\software\Anaconda\lib\site-packages\scanpy\__init__.py", line 32, in <module>
    from . import tools as tl
  File "C:\software\Anaconda\lib\site-packages\scanpy\tools\__init__.py", line 12, in <module>
    from ._sim import sim
  File "C:\software\Anaconda\lib\site-packages\scanpy\tools\_sim.py", line 24, in <module>
    from .. import readwrite
  File "C:\software\Anaconda\lib\site-packages\scanpy\readwrite.py", line 10, in <module>
    import tables
  File "C:\Users\xiaokang\AppData\Roaming\Python\Python36\site-packages\tables\__init__.py", line 99, in <module>
    from .utilsextension import (
ImportError: DLL load failed: 找不到指定的模块。

At last I uninstalled the tables package and install the tables package again,then it works fine to me

Upvotes: 0

McMillenandhiswife
McMillenandhiswife

Reputation: 146

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!

Upvotes: 1

Related Questions