2015-07-21 21 views
4

我使用Python 2.7.2 | EPD 7.1-1(64位),由於某種原因numpy.random.choice不工作:numpy.random有沒有屬性「選擇」

從終端窗口:

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' 

什麼問題可能是什麼想法?

謝謝

+1

'NP .__ version__'? – cphlewis

回答

4

我認爲它可能是你的發行版使用的numpy版本。從the documentation選擇只添加在1.7.0和從the enthought package我可以看到它只有在版本7.2,比你自己的更高版本1.6.1。你可能希望升級你的numpy版本。

+0

我認爲你是對的,那是問題所在。我升級到Canopy和我的numpy版本現在是1.9.2,它的工作原理。 謝謝!!!!! – Laura

1

它有randint

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

應該做同樣的事情

相關問題