numpy.random 没有属性 'choice'

numpy.random has no attribute 'choice'

我正在使用 python 2.7.2 |EPD 7.1-1(64 位)并且由于某些原因 numpy.random.choice 无法正常工作:

从终端 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'

知道问题出在哪里吗?

谢谢

我认为这可能是您的发行版使用的 numpy 版本。从the documentation choice was only added in 1.7.0 and from the enthought package我看到7.2版本只有1.6.1,比你的版本高。您可能希望升级您的 numpy 版本。

它有randint吗?

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

应该做同样的事情