0

I am trying to import a module that imports a module. But that doesnt work. This is my folder hierarchy:

/Project/
-test.py
     /recognizer/
     -__init__.py
     -tools.py
     -feature_extraction.py

I am importing tools.py inside of feature_extraction.py. If I run the feature_extraction.py it all works like it should. Now I want to import the feature_extraction.py from the test.py, but that doesnt work. I get this error ModuleNotFoundError: No module named 'tools'.

Inside the test.py I am importing like this from recognizer import feature_extraction that works like it should I think. Inside of feature_extraction.py I am importing just like this import tools. This should work I think, but it doesnt.

1
  • 1
    try to import tools like this from . import tools Commented May 2, 2020 at 19:55

2 Answers 2

2

You should do this way.

from . import tools

If you import tools from feature_extraction.py file. it will lookup main directory which test.py lays.

Sign up to request clarification or add additional context in comments.

Comments

0

try to import in feature_extraction tools like this: import recognizer.tools

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.