Numpy.random does not have the 'choice' attribute

I am using python 2.7.2 | EPD 7.1-1 (64-bit) and for some reason numpy.random.choice does not work:

from the terminal window:

d-108-179-168-72:~ home$ python
Enthought Python Distribution -- www.enthought.com
Version: 7.1-1 (64-bit)

Python 2.7.2 |EPD 7.1-1 (64-bit)| (default, Jul  3 2011, 15:56:02) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "packages", "demo" or "enthought" for more information.
>>> import numpy as np
>>> np.random.choice(5, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'choice'

any ideas on what could be the problem?

thank

+4
source share
2 answers

I think it might be the numpy version that your distribution uses. From the documentation selection was added only in 1.7.0 and from the enthought package I see that it has only 1.6.1 in version 7.2, a later version than yours. You might want to upgrade your numpy version.

+4
source

Does he have randint?

np.random.randint(0,5,3)

should do the same

+1
source

Source: https://habr.com/ru/post/1598981/


All Articles