Import Error DGL with PyTorch

Hi,

I have an error while importing DGL library. Shows a ‘.dll’ file missing, however it is available when I look in the mentioned path. Any suggestions?

System Settings
Cuda: Not available
Installation: pip install dgl
torch version: 1.8.1
numpy | scipy: 1.20.3 | 1.6.3
Python: 3.8.8

Traceback
import dgl
Traceback (most recent call last):
File “”, line 1, in
File “C:\Program Files\JetBrains\PyCharm 2021.1.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py”, line 21, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\Users\n832\PycharmProjects\Sandbox\venv\lib\site-packages\dgl_init
.py", line 13, in
from .backend import load_backend, backend_name
File “C:\Program Files\JetBrains\PyCharm 2021.1.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py”, line 21, in do_import
module = self.system_import(name, *args, **kwargs)
File "C:\Users\n832\PycharmProjects\Sandbox\venv\lib\site-packages\dgl\backend_init
.py", line 95, in
load_backend(get_preferred_backend())
File “C:\Users\n832\PycharmProjects\Sandbox\venv\lib\site-packages\dgl\backend_init_.py”, line 41, in load_backend
from …_ffi.base import load_tensor_adapter # imports DGL C library
File “C:\Program Files\JetBrains\PyCharm 2021.1.1\plugins\python\helpers\pydev_pydev_bundle\pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File “C:\Users\n832\PycharmProjects\Sandbox\venv\lib\site-packages\dgl_ffi\base.py”, line 44, in
_LIB, _LIB_NAME, _DIR_NAME = _load_lib()
File “C:\Users\n832\PycharmProjects\Sandbox\venv\lib\site-packages\dgl_ffi\base.py”, line 34, in load_lib
lib = ctypes.CDLL(lib_path[0])
File "C:\Users\n832\AppData\Local\Programs\Python\Python38\lib\ctypes_init
.py", line 373, in init
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module ‘C:\Users\n832\PycharmProjects\Sandbox\venv\lib\site-packages\dgl\dgl.dll’ (or one of its dependencies). Try using the full path with constructor syntax.

1 Like

What’s your DGL version? Also, does the error still happen if you import DGL outside PyCharm?

Hi I was able to solve this issue.
For others stumbling on this issue, please check if Visual C++ version 2014 exactly is installed in your OS.

Thanks

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.