Undefined symbol: _ZTIN5torch8autograd4NodeE

When ‘import torch’ in Python3, it shows the following problem:

Python 3.7.5rc1 (default, Oct  2 2019, 04:19:31) 
[GCC 9.2.1 20190909] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/python3.7/lib/python3.7/site-packages/torch/__init__.py", line 81, in <module>
    from torch._C import *
ImportError: /opt/python3.7/lib/python3.7/site-packages/torch/lib/libtorch_python.so: undefined symbol: _ZTIN5torch8autograd4NodeE
>>> 

Any idea what the problem would be? Thanks.

Did you install PyTorch from source or a binary?
Was PyTorch working at some point in the past or is this your first installation?

Could you post which command you’ve used to install PyTorch?

I used pip to install PyTorch as in

pip3 install torch torchvision

PyTorch used to work on my system (Debian 9) and it broke after I upgraded some system components (I don’t remember what exactly).

In that case I would recommend to reinstall the latest PyTorch version.
Let us know, if you still have trouble.

After updating Python3.7 and reinstalling PyTorch, the error persists:

Python 3.7.5 (default, Oct 27 2019, 15:43:29) 
[GCC 9.2.1 20191022] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/python3.7/lib/python3.7/site-packages/torch/__init__.py", line 81, in <module>
    from torch._C import *
ImportError: /opt/python3.7/lib/python3.7/site-packages/torch/lib/libtorch_python.so: undefined symbol: _ZTIN5torch8autograd4NodeE
>>>