在Python中努力处理导入问题

问题描述 投票:-1回答:1

我只是想从Python的嵌套包中导入模块。

project root目录中执行命令后:

$ nosetests

不幸的是,我仍然收到这样的日志:

======================================================================
ERROR: Failure: ImportError (No module named io_file)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/user/dev/ease-ci/easeci-core/tests/lib/io/test_io_facade.py", line 4, in <module>
    from lib.io.io_file import file_load, File, file_exist, file_save, file_delete, file_change
ImportError: No module named io_file

以及越来越多的此类错误。有人可以告诉我一些帮助我解决问题的方法吗? 谢谢。

Project structure

Pycharm让我错了,因为如果我用绿色箭头进行测试,一切都会好起来的。enter image description here

python structure nose
1个回答
0
投票

我猜您正在尝试安装未安装pip的库,因为您以weird的方式使用了pycharm。尝试将路径添加到必须下载的库中,然后在代码中运行导入。干杯!

import tensorflow as tf

https://www.jetbrains.com/help/pycharm/absolute-path-variables.html

© www.soinside.com 2019 - 2024. All rights reserved.