0

I am trying to import a class from a separate file into one of my modules. I have two files sampleModule and classB both in the same folder. Inside classB I have:

class CLASSB(object):
    def __init__(self, x):
        self.x = x

Inside sampleModule, I have:

from classB import CLASSB

But in sampleModule I get this error:

Unresolved import: CLASSB
Unused import: CLASSB

I also have an _init_.py in the same folder

How do I fix this issue?

EDIT: Computer restart fixed issue.

SKLAK
  • 3,825
  • 9
  • 33
  • 57
  • Just to check, the file is called `classB.py` instead of `classB` right? – Wolph Sep 23 '13 at 20:54
  • just curiosity: how many underscores You have in `_init_.py` file name ? – oleg Sep 23 '13 at 20:58
  • What version of python are you using? I've never seen this kind of error before – Paco Sep 23 '13 at 20:58
  • this looks like message of some code analysis tool – oleg Sep 23 '13 at 20:59
  • Probably relevant: http://stackoverflow.com/questions/4631377/unresolved-import-issues-with-pydev-and-eclipse – Shashank Sep 23 '13 at 21:04
  • class CLASSB ``def __init__`` is missing a colon. When I add this and set up example structure as you describe, ``import sampleModule`` works fine. No sign of the "unresolved import" problem – Vorsprung Sep 23 '13 at 21:12
  • The colon's there, I just forgot to include it when typing the question. I am using python 2.7. I have two underscores for __init__.py. The file is called classB.py – SKLAK Sep 23 '13 at 21:30
  • "I just forgot to include it when typing the question" - you retyped your code into the question box? Don't do that. Copy and paste it from your actual source code, or we'll waste time trying to figure out what your code actually looks like and trying to guess at things you didn't realize were relevant. – user2357112 Sep 23 '13 at 21:35
  • The issue is fixed, the error went away when I restarted my computer.. weird. – SKLAK Sep 23 '13 at 21:36

0 Answers0