numpy.random没有属性' choice'

时间:2015-07-21 23:31:54

标签: python numpy enthought

我使用的是python 2.7.2 | EPD 7.1-1(64位),由于某种原因,numpy.random.choice无效:

从终端窗口

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'

关于问题可能是什么的任何想法?

感谢

2 个答案:

答案 0 :(得分:4)

我认为它可能是您的发行版正在使用的numpy版本。来自the documentation的选项仅在1.7.0和the enthought package中添加。我可以看到它在版本7.2中只有1.6.1,比您自己的版本晚。您可能希望升级您的numpy版本。

答案 1 :(得分:1)

是否有randint

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

应该做同样的事情