ImportError无法导入名称

时间:2015-10-03 22:00:59

标签: python

我正在尝试使用以下导入运行unittest:

from LinearProbeTable import Dictionary
import unittest
import string
import random
class TestDictionary(unittest.TestCase):
    (testing code)

在LinearProbeTable中,我导入了一个例外:

from Exceptions import DictFullError

DictFullError定义为(在Exceptions.py中):

class DictFullError(Exception):
    pass

当我尝试运行测试时,我得到以下回溯:

Traceback (most recent call last):
  File "/Applications/PyCharm Educational.app/Contents/helpers/pycharm/utrunner.py", line 135, in <module>
    module = loadSource(a[0])
  File "/Applications/PyCharm Educational.app/Contents/helpers/pycharm/utrunner.py", line 40, in loadSource
    module = imp.load_source(moduleName, fileName)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/andrewsalter/.../Prac 9/Testing/task1_autotest.py", line 1, in <module>
    from LinearProbeTable import Dictionary
  File "/Users/andrewsalter/.../Prac 9/LinearProbeTable.py", line 1, in <module>
    from Exceptions import DictFullError
ImportError: cannot import name 'DictFullError'

我没有循环依赖,所以我不确定发生了什么。

我正试图在我的笔记本电脑上运行它,但它在我的桌面上工作(我把它全部托管在谷歌驱动器上 - 我知道我应该使用Git但我还没有解决它)

编辑:可能是因为LinearProbeTable.py位于测试脚本的父文件夹中?

0 个答案:

没有答案