模块' ants'没有属性' from_numpy'
我正在jupyter笔记本上工作,并使用pip安装蚂蚁领域:
pip install antspyx
但是,使用函数from_numpy
引发错误:
import ants
Im2Use=Im[0,:,:,:]
fixed, moving, mytx=reg(Im2Use, t_rz)
fwdtransforms=mytx['fwdtransforms']
fixed_ants= ants.from_numpy(Im2Use.astype(float))
moving_ants= ants.from_numpy(t_rz.astype(float))
mywarpedimage=ants.apply_transforms( fixed=fixed_ants, moving=moving_ants,transformlist=fwdtransforms)
AttributeError: module 'ants' has no attribute 'from_numpy'
如何解决此问题?我还尝试使用导入蚂蚁导入蚂蚁。from_numpy
,但这无效。
I am working in a jupyter notebook, and used pip to install ANTsPy:
pip install antspyx
However, using the function from_numpy
throws an error:
import ants
Im2Use=Im[0,:,:,:]
fixed, moving, mytx=reg(Im2Use, t_rz)
fwdtransforms=mytx['fwdtransforms']
fixed_ants= ants.from_numpy(Im2Use.astype(float))
moving_ants= ants.from_numpy(t_rz.astype(float))
mywarpedimage=ants.apply_transforms( fixed=fixed_ants, moving=moving_ants,transformlist=fwdtransforms)
AttributeError: module 'ants' has no attribute 'from_numpy'
How can I solve this? I've also tried importing ants using import ants.from_numpy
, but that did not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您负责激活Virtualenv,请指定您的IDE+吗?
无论如何,这里是确保python模块预测安装在虚拟环境中的步骤:
python3 -m venv env_name
:这将在您的当前路径source> source incouse env/bin 在Windows上仅在CD中激活您的Env Name
。
pip install antspyx
,然后使用pip list
检查您的终端中,如果该软件包是在软件包中安装的,Can you please specify your IDE+ if you took care of activating the virtualenv?
Anyways here are the steps to make sure that the python module is propoerly installed in your virtual environment :
python3 -m venv env_name
: this will create a virtual env in your current pathsource env/bin/activate
: this will activate your virtual env (if on windows just cd into activate within your env name.\env\Scripts\activate
pip install antspyx
then check withpip list
and see in your terminal if the package is propoerly installed您是否尝试过:
have you tried:
在这种情况下,问题是Scipy版本控制。我从版本1.7.3降级到1.2.0版,然后解决了问题。为什么?这是因为蚂蚁库期望在scipy.misc中使用一个称为“阶乘”的功能,但版本1.7.3移动了阶乘的位置。
The issue in this case was scipy versioning. I downgraded from version 1.7.3 to version 1.2.0, which then solved the problem. Why? It's because ants library expects a function called "factorial" in scipy.misc, but version 1.7.3 moved the location of factorial.