[英]numpy.random has no attribute 'choice'
I am using python 2.7.2 |EPD 7.1-1 (64-bit) and for some reason numpy.random.choice is not working: 我使用python 2.7.2 | EPD 7.1-1(64位),由于某种原因numpy.random.choice无法正常工作:
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 谢谢
I think it could be the version of numpy your distribution is using. 我认为它可能是您的发行版使用的numpy版本。 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.
从文档中选择仅在1.7.0中添加,并且从enthought包中我可以看到它在版本7.2中只有1.6.1,比您自己的版本晚。 You may wish to upgrade your version of numpy.
您可能希望升级您的numpy版本。
Does it have randint
? 它有
randint
吗?
np.random.randint(0,5,3)
should do the same thing 应该做同样的事情
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.