ImportError:没有名为integrate [duplicate]的模块

时间:2022-04-11 23:15:53

This question already has an answer here:

这个问题在这里已有答案:

I tried to solve a differential equation using lib odient in python, and this is what I wrote in gedit editor:

我试图在python中使用lib odient来解决微分方程,这就是我在gedit编辑器中写的:

# -*- coding: utf-8  -*-
from __future__ import division 
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import numpy as np
def phi(y,t):
    return 1.5*y*(1-y/6)

y0 = 1.0
t =np.linspace(0,5,201)
sol = odeint(phi,y0,t)

plt.plot(t,sol)
plt.show()

and everytime I try to execute it in terminal, here's what I get: ImportError: No module named integrate

每当我尝试在终端中执行它时,这就是我得到的:ImportError:没有名为integrate的模块

but when I try execute it using Ipython everything goes normal, here's a screenshot: pic2

但是当我尝试使用Ipython执行它时,一切正常,这是截图:pic2

can you please help me? thanks.

你能帮我么?谢谢。

1 个解决方案

#1


0  

You may be missing scipy module.

您可能缺少scipy模块。

Please Install it first.

请先安装它。

$ sudo pip2 install scipy

I managed to run your program after installing additional requirement

我设法在安装附加要求后运行您的程序

$ sudo pip2 install matplotlib
$ sudo apt install python-tk 

#1


0  

You may be missing scipy module.

您可能缺少scipy模块。

Please Install it first.

请先安装它。

$ sudo pip2 install scipy

I managed to run your program after installing additional requirement

我设法在安装附加要求后运行您的程序

$ sudo pip2 install matplotlib
$ sudo apt install python-tk