AttributeError: type object 'torch._C._TensorBase' has no attribute '__idiv__'

I got an error of “AttributeError: type object ‘torch._C._TensorBase’ has no attribute ‘idiv’” when I try to run “import torch”. It prints out error message like this:

Has anyone ever had the same problem? How to solve this problem?

Thank you.

Could you create a new virtual environment and reinstall PyTorch there?
Alternatively, uninstall all PyTorch installations from the current environment and reinstall it. Make sure to run the uninstall commands multiple times, as e.g. binary installations might have been installed on top of source builds.

PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier and enables the forum search to index the post. :wink:

Many thanks for your kind help, I have solved this issue by creating a new virtual environment.

Best Regards