Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

multiarray failed to import error

📅 2019-Jul-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ pytorch ⬩ 📚 Archive


I installed PyTorch locally using pip3. And then I wrote my first PyTorch program that had this import at the top: import torch.nn as nn.

When I ran the script, that import failed with this error:

Traceback (most recent call last):
  File "./", line 3, in <module>
    import torch.nn as nn
  File "/home/ashwin/.local/lib/python3.6/site-packages/torch/", line 79, in <module>
    from torch._C import *
ImportError: numpy.core.multiarray failed to import


I have faced this problem many times in different environments. It has always been due to clashes between multiple NumPy libraries installed on the system.

Here are the solutions that worked for me:

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧