4

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

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 of what the problem could be?

thanks

Laura
  • 1,822
  • 3
  • 15
  • 23

2 Answers2

4

I think it could be the version of numpy your distribution is using. From the documentation choice was only added in 1.7.0 and from the enthought package I can see it only has 1.6.1 in version 7.2, a later version than your own. You may wish to upgrade your version of numpy.

BitOfABeginner
  • 122
  • 1
  • 10
  • I think you are right, that was the problem. I upgraded to Canopy and my numpy version is now 1.9.2 and it works. Thanks!!!!! – Laura Jul 22 '15 at 18:46
1

Does it have randint?

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

should do the same thing

hpaulj
  • 221,503
  • 14
  • 230
  • 353