如何修复ImportError

时间:2019-05-29 19:20:21

标签: python python-3.x python-2.7 python-import

因此,我坚持如何解决imresize的导入错误。我已经安装了所需的所有东西,例如安装枕头,但是我找不到解决方案。另外,我尝试运行的代码也来自此github链接https://github.com/CSAILVision/IBD 另外请注意,我不拥有此代码,也不是其原始代码。这是我一个不同的研究项目。另外,我尝试向原始的arthor进行修复,但根本没有收到他们的回复。

安装Pillow,替换为代码:从scipy.misc.pilutil导入导入,安装Pillow-3.3.1-cp27-cp27m-win32.whl,卸载Pil并安装Pillow,重新安装Pillow。

from util.image_operation import *
from PIL import Image
import numpy as np
from imageio import imresize, imread
from visualize.plot import random_color
from torch.autograd import Variable as V
import torch

我希望它可以运行,但是可以打印出图像,但不能。

Traceback (most recent call last):


     File "test.py", line 4, in <module>
        from loader.model_loader import loadmodel

      File "/home/joshuayun/Desktop/IBD/loader/model_loader.py", line 5, in <module>


     from util.feature_operation import hook_feature, hook_grad
      File "/home/joshuayun/Desktop/IBD/util/feature_operation.py", line 6, in <module>
        from imageio import imresize, imread, imsave
    ImportError: cannot import name 'imresize'

3 个答案:

答案 0 :(得分:1)

我有同样的问题,我的系统是1.4。我做了以下工作,而且有效-

pip install scipy==1.1.0

答案 1 :(得分:0)

如果您想按原样使用代码,我建议创建一个新环境,并安装旧版本的Uncaught Error: Syntax error, unrecognized expression: [data-label="Item "2""] at Function.ga.error (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at ga.tokenize (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at ga.compile (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at ga.select (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at ga (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at Function.ga.matches (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at Function.r.filter (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at E (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at r.fn.init.filter (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:2) at c.setLabel (eNptjUsOgzAMRE9E2XMbEwwkcmxjJ6qQenh-i6qF1UhvnmbUYsYRAnqXloq2tle8kn_02wUxvKGswsjF_4qfnUapTpFPp1KJGRqCVWrpkrcMLB5MiNAeBX9HPX9n8HmAAgecSHqgnW7lbUr_.js.xhtml?ln=omnifaces.combined&v=1558274343370:38) (0.19.1应该可以解决问题)。在新环境中,假设您正在使用conda,请执行以下操作:

scipy

如果您使用pip代替:

conda install scipy==0.19.1

答案 2 :(得分:0)

自从scipy 1.3.0rc1 resize成为removed