I'm having some trouble getting importing stuff from another class, I think I may be doing it wrong.

I have a simple main class called Test and at the top I say:

from WordFixer import WordFixer
import sys

Then in the same folder (the src folder) I have a file called WordFixer.py and it's heading says:

class WordFixer:

but I'm getting an error in Test that says "Unresolved import: WordFixer"

What am I doing wrong?

Recommended Answers

Sometimes, if the module isn't in the same place, it is a matter of the path. At the begging of your progam you can do something like:

import sys
sys.path.append('/path/tomy/module')
from MyMod import moduleA

However I don't know how Eclipse as an IDE differs in terms of …

Jump to Post

sys.path.append('/path/tomy/module')

module is a file or folder ?

Jump to Post

All 5 Replies

Well it seems to work now although I'm not sure why...I commented out the line and uncommented it a little bit later. I'm using eclipse. Maybe I should have forced it to compile or something.

Sometimes, if the module isn't in the same place, it is a matter of the path. At the begging of your progam you can do something like:

import sys
sys.path.append('/path/tomy/module')
from MyMod import moduleA

However I don't know how Eclipse as an IDE differs in terms of working directory...

sys.path.append('/path/tomy/module')

module is a file or folder ?

either

I guess ungalcrys has left Python a long time ago.
This is his only post over 4 year ago,look at dates.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.