0

I didn't make any change but it suddenly doesn't work.

>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cheng/anaconda/envs/py36/lib/python3.6/site-packages/torch/__init__.py", line 56, in <module>
    from torch._C import *
ImportError: numpy.core.multiarray failed to import

I tried pip install numpy -I but it didn't work.

My OS is Mac OS X, and I tried to install by both pip and conda. Reinstall the env didn't work as well.

pytorch version 0.3.1

numpy version 1.14.2

Solution:

Do not name your file tokenize.py!

Shiloh_C
  • 197
  • 4
  • 13

2 Answers2

1

Solution according to OP:

A file named tokenize.py in the current directory caused this issue.

MBT
  • 21,733
  • 19
  • 84
  • 102
0

I'd same error and I solved it with change version of numpy.

Result of import torch

$ python

Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

import torch

** On entry to DGEBAL parameter number 3 had an illegal value

** On entry to DGEHRD parameter number 2 had an illegal value

** On entry to DORGHR DORGQR parameter number 2 had an illegal value

** On entry to DHSEQR parameter number 4 had an illegal value

Traceback (most recent call last):

File "", line 1, in

File "C:\Projects\Aspose\lib\site-packages\torch_init_.py", line 190, in from torch._C import *

ImportError: numpy.core.multiarray failed to import

Result of import numpy

import numpy

** On entry to DGEBAL parameter number 3 had an illegal value

** On entry to DGEHRD parameter number 2 had an illegal value

** On entry to DORGHR DORGQR parameter number 2 had an illegal value

** On entry to DHSEQR parameter number 4 had an illegal value

Traceback (most recent call last):

File "", line 1, in

File "C:\Projects\Aspose\lib\site-packages\numpy_init_.py", line 305, in win_os_check()

File "C:\Projects\Aspose\lib\site-packages\numpy_init.py", line 302, in _win_os_check raise RuntimeError(msg.format(file)) from None

RuntimeError: The current Numpy installation ('C:\Projects\Aspose\lib\site-packages\numpy\init.py') fails to pass a sanity check due to a bug in the windows runtime.

Solution:

pip uninstall numpy

pip install numpy==1.19.3

Dharman
  • 30,962
  • 25
  • 85
  • 135
Volkov Maxim
  • 191
  • 2
  • 7