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.

asked May 2, 2020 at 19:45
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.

answered May 2, 2020 at 19:56
0

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

answered May 2, 2020 at 20:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.