2017-03-07 5 views
0

scipy를 다운로드하고 가져온 것을 알 때 "NameError : name 'scipy'is not defined"가 계속 나타납니다.NameError : name 'scipy'가 정의되지 않았습니다.

팁이 있습니까?

여기 내 코드입니다 :

import scipy.integrate as integrate 

exact = scipy.integrate.ode(eq1) 
print(exact) 

감사합니다! 당신이 scipy.integrate.ode(eq1)에서 이름 오류가 발생하는 이유

+0

그래, 같은없이 다른 기능을 사용할 수 있습니다

import scipy 

로 가져 구리 필드가 말하길, integip.ode가 아니라 scipy.integrate. – SuperTetelman

+2

이 코드에는'import scipy'가 없습니다 ... –

+0

scipy가 설치되어 있고 실제로 가져올 수 있다는 것을 어떻게 알 수 있습니까? 그렇지 않으면 오류가 발생합니다. –

답변

0

import scipy.integrate as integrate 

exact = integrate.ode(eq1) #notice, no scipy 
print(exact) 

문제를 시도하면 import 모듈 scipy.integrate하고 지시 as와 변수 integrate에 바인딩이다, 즉, scipy이 아닌 당신의 네임 스페이스, 단지 integrate; 당신이 scipy을 포함 할 경우

그 다음 그래서 당신은

import scipy.integrate as integrate 
import scipy 
exact = integrate.ode(eq1) 
print(exact) 

아니면 그냥 as

import scipy.integrate 

exact = scipy.integrate.ode(eq1) 
print(exact) 
+0

@ cricket_007 업데이트보기 – Copperfield

+0

이제 감각을 갖습니다. –

관련 문제