MacOS conda install fails

I have factory reset my iMac today. Installed latest Anaconda, created env, activated env, followed instructions here.

This is the error message I receive when I try to run any code with torch.

  File "", line 1, in <module>
    import torch
  File "/Users/reubenschmidt/code/python/nn/cxr_net/", line 3, in <module>
    x = torch.rand(5,3)
AttributeError: partially initialized module 'torch' has no attribute 'rand' (most likely due to a circular import)

Terminal conda list | grep torch result:

pytorch                   1.4.0                   py3.8_0    pytorch
torchvision               0.5.0                  py38_cpu    pytorch

This issue has been discussed previously here:

Any thoughts would be much appreciated. Cheers.


This most likely happens because you have a local file called And so when you do import torch, it tries to import that local file instead of the torch library. You should not have a file (or folder) with the same name as a library you use locally to avoid issues :slight_smile:


Thank you so much for your help albanD. That was a really dumb mistake on my behalf!

I owe you one. Cheers.

There are so many names I can have. Why I have to name it as!!! Thank you for your questions. This helps me!