Forum Archive

Error importing numpy

Flavin

I wrote a script in Pythonista that failed on the first line, importing numpy. I tried just running that import line in the console, and it also failed.

>>> import numpy as np
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/var/containers/Bundle/Application/2D5E7A73-E48B-4CA6-8789-B800F22ADF1D/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/numpy/__init__.py", line 172, in <module>
    from . import random
  File "/var/containers/Bundle/Application/2D5E7A73-E48B-4CA6-8789-B800F22ADF1D/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/numpy/random/__init__.py", line 104, in <module>
    ranf = random = sample = random_sample
NameError: name 'random_sample' is not defined

Is this a bug? I haven’t installed anything custom and this seems to be attempting to use the packaged numpy installation.

mikael

@Flavin, have you tried restarting Pythonista?

Flavin

@mikael I have now. That seems to have fixed it.

mikael

@Flavin, excellent. It has been noted here before that numpy is such a large and complex library that it may fail to load properly.