2016-08-10 103 views
0

我安装康达(我在Spyder的工作)成功地scitools_no_easyviz,但我不能导入的情节。更具体地讲,这里是我的代码名“阴谋”没有定义

from scitools.std import * 

def f(t): 
    return t**2*exp(-t**2) 

t = linspace(0, 3, 51) 
y = f(t) 
plot(t, y) 

savefig('tmp1.pdf') # produce PDF 
savefig('tmp1.png') # produce PNG 

figure() 

def f(t): 
    return t**2*exp(-t**2) 

t = linspace(0, 3, 51) 
y = f(t) 
plot(t, y) 
xlabel('t') 
ylabel('y') 
legend('t^2*exp(-t^2)') 
axis([0, 3, -0.05, 0.6]) # [tmin, tmax, ymin, ymax] 
title('My First Easyviz Demo') 

figure() 
plot(t, y) 
xlabel('sss') 

当我运行代码,我收到以下错误

NameError:名字“阴谋”是没有定义

可能是什么问题呢?

回答

0

使用import *不被认为是最好的做法,但很实用。尝试导入您需要的功能,如:

from scitools.std import plot 

此外,这样你就会知道,如果“情节”是有效的,当你导入它的旁边任何其他功能。

确保已安装才能使用的封装指出here依赖于https://code.google.com/archive/p/scitools/wikis/Installation.wiki

此外,安装以下这些指令latest package和你的代码运行非常顺利地使用它。

+0

我照你说的,但现在我得到这个错误: 导入错误:无法导入名称情节 –

+0

也许情节不再是一个有效的功能,或至少为您正在使用的Python版本,您使用的是什么版本scitools的? – glls

+0

scitools_no_easyviz 0.9.0,python 2.7.12 –