【问题标题】:ImportError: No module named - python anacondaImportError:没有命名的模块 - python anaconda
【发布时间】:2016-01-16 19:39:27
【问题描述】:

我只想运行那里给出的代码:https://github.com/skaae/lasagne-draw

这是lasagne-draw-master文件下载后的目录结构:

lasagne-draw-master\

    -->\deepmodels
        --> __init__.py, batchiterator.py, confusionmatrix.py
        -->\layers
             --> __init__.py, draw.py, draw_helpers.py, draw_helpers_test.py

    -->\examples
        --> mnist_draw.py, helper_functions.py

对于安装,我必须在安装 Theano 和 Lasagne 后执行这些步骤,如自述文件中所述。我也在 lasagne-draw-master 目录上。

python setup.py develop

cd ..

python -c 'import deepmodels'

以上两个命令完美执行。但是当我执行第三个命令时,它显示了这个错误:

File "<string>", line 1, in <module>
File "deepmodels\__init__.py", line 2, in <module>
  from . import layers
File "deepmodels\layers\__init__.py", line 1, in <module>
  from .base import *
ImportError: No module named base

deepmodels__init__.py 的内容是:

from . import confusionmatrix
from . import layers
from . import batchiterator

deepmodels\layers__init__.py 的内容是:

from .base import *
from .draw import *

我正在使用 python anaconda。 init.py 文件或其他文件中是否有任何语法错误?

【问题讨论】:

    标签: python python-2.7 github anaconda


    【解决方案1】:

    我刚刚发现了问题并通过对 init.py 和 draw.py(在层目录中)文件中的修改进行了解决。

    deepmodels/init.py
    
    change followings
    
    from . import confusionmatrix
    from . import layers
    from . import batchiterator
    
    to follows; 
    
    import confusionmatrix
    import layers
    import batchiterator
    
    deepmodels/layers/init.py
    
    change followings 
    
    from .base import *
    from .draw import *
    
    to as follows; 
    
    from lasagne.layers.base import *
    from draw import *
    
    deepmodels/layers/draw.py
    
    line 8
    comment out from .. import logdists
    

    【讨论】:

      猜你喜欢
      • 2019-12-12
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      • 2017-06-13
      • 2016-04-06
      • 1970-01-01
      相关资源
      最近更新 更多