Python f2py 重新加载更改的模块
Python f2py reload changed module
我是编程新手 python
。我设法使用 f2py
将堡垒 运行 模块导入 python
。但是有一个小问题我无法弄清楚。当我更改 fort运行 代码并再次使用 f2py
刷新模块时,编译器仍然识别模块的第一个版本。我怎样才能强制它刷新模块?我读过 importlib.reload
,但它对我没有任何改变。我指的是 python3.7
.
要塞运行代码二.f90为:
module two
implicit none
contains
subroutine twofunc(x,y)
real,intent(in) :: x
real,intent(out) :: y
y = x*x
end subroutine twofunc
end module
然后我将其更改为:
module two
implicit none
contains
subroutine twofunc(x,y)
real,intent(in) :: x
real,intent(out) :: y
y = x*x*x
end subroutine twofunc
end module.
这只是一个测试代码。
然后,我运行 f2py。然后在 Spyder 中:
import importlib
import two
importlib.reload(one10)
y=two.two.twofunc(4)
print(y)
尽管将代码从 x^2 更改为 x^3,结果仍然是 16。
reload
命令并非对所有情况都有效。 f2py模块,可能是编译后的代码,一般不能重新加载
您需要重新启动内核以迭代扩展模块开发(菜单 "consoles" -> 重新启动内核或在控制台选项卡上右键单击 -> 重新启动内核)。
我是编程新手 python
。我设法使用 f2py
将堡垒 运行 模块导入 python
。但是有一个小问题我无法弄清楚。当我更改 fort运行 代码并再次使用 f2py
刷新模块时,编译器仍然识别模块的第一个版本。我怎样才能强制它刷新模块?我读过 importlib.reload
,但它对我没有任何改变。我指的是 python3.7
.
要塞运行代码二.f90为:
module two
implicit none
contains
subroutine twofunc(x,y)
real,intent(in) :: x
real,intent(out) :: y
y = x*x
end subroutine twofunc
end module
然后我将其更改为:
module two
implicit none
contains
subroutine twofunc(x,y)
real,intent(in) :: x
real,intent(out) :: y
y = x*x*x
end subroutine twofunc
end module.
这只是一个测试代码。 然后,我运行 f2py。然后在 Spyder 中:
import importlib
import two
importlib.reload(one10)
y=two.two.twofunc(4)
print(y)
尽管将代码从 x^2 更改为 x^3,结果仍然是 16。
reload
命令并非对所有情况都有效。 f2py模块,可能是编译后的代码,一般不能重新加载
您需要重新启动内核以迭代扩展模块开发(菜单 "consoles" -> 重新启动内核或在控制台选项卡上右键单击 -> 重新启动内核)。