错误linspace()得到了一个意外的关键字参数' dtype'只在窗口

时间:2015-03-16 08:47:42

标签: python windows numpy pip canopy

我有一个脚本,我在Red Hat 4.4.7上运行成功:

>>> import numpy
>>> numpy.version.version
'1.9.1'
>>> numpy.linspace(3,4,5,dtype=int)
array([3, 3, 3, 3, 4])

在我的Windows安装上,即使更新numpy(pip install -U numpy)后,我也收到错误:

In[3]: import numpy
In[4]: numpy.version.version
Out[4]: '1.9.1'
In[5]: numpy.linspace(3,4,5,dtype=int)
Traceback (most recent call last):
File "C:\Users\lb\AppData\Local\Enthought\Canopy\User\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-cce2ab26cfad>", line 1, in <module>
numpy.linspace(3,4,5,dtype=int)
TypeError: linspace() got an unexpected keyword argument 'dtype'

为什么这种行为不同?除了numpy版本,我还应该检查什么?

编辑:

print(repr(numpy.core.function_base))
<module 'numpy.core.function_base' from 'C:\Users\lb\AppData\Local\Enthought\Canopy\User\lib\site-packages\numpy\core\function_base.pyc'>

print(repr(numpy.__path__))
['C:\\Users\\lb\\AppData\\Local\\Enthought\\Canopy\\User\\lib\\site-packages\\numpy']

print(numpy.linspace.__module__)
numpy.core.function_base

在C:\ Users \ lb \ AppData \ Local \ Enthought \ Canopy \ User \ Lib \ site-packages \ numpy \ core \ function_base.py的第8行,我有:

def linspace(start, stop, num=50, endpoint=True, retstep=False):

所以,我想我搞砸了pip更新......

0 个答案:

没有答案