No module named 'tensorflow'?


I tried to install dgl, but it seems somethings wrong and I do not know how to fix it. Notably, I have already installed pytorch.

import dgl
Traceback (most recent call last):
File “”, line 1, in
File “/home/deep/anaconda3/envs/torch-1.9/lib/python3.5/site-packages/dgl/”, line 8, in
from .backend import load_backend, backend_name
File “/home/deep/anaconda3/envs/torch-1.9/lib/python3.5/site-packages/dgl/backend/”, line 74, in
File “/home/deep/anaconda3/envs/torch-1.9/lib/python3.5/site-packages/dgl/backend/”, line 23, in load_backend
mod = importlib.import_module(’.%s’ % mod_name, name)
File “/home/deep/anaconda3/envs/torch-1.9/lib/python3.5/importlib/”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “/home/deep/anaconda3/envs/torch-1.9/lib/python3.5/site-packages/dgl/backend/tensorflow/”, line 4, in
from .tensor import *
File “/home/deep/anaconda3/envs/torch-1.9/lib/python3.5/site-packages/dgl/backend/tensorflow/”, line 6, in
import tensorflow as tf
ImportError: No module named ‘tensorflow’

What was your DGL version? I think it by default should use PyTorch, but you can take a look at your DGLBACKEND environment variable or ~/.dgl/config.json and see if any of them contains “tensorflow”.

Also DGL no longer supports Python 3.5 officially.

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