2

I have a file calc.py where I have methods for basic calculations.Now I crate another file (in the same directory) called test_calc.py for unittesting the methods in calc.py file.But in the test_calc.py file,when I type import calc, it says 'no such module'.If I am in the same directory,why can't I import calc?

Here is a screen shot of my project structure enter image description here

This is what I get when I try to import calc into the test_calc.py file enter image description here

So what is going wrong?

Souvik Ray
  • 2,899
  • 5
  • 38
  • 70

1 Answers1

2

Try at least, as recommended here

 from . import calc

Python 3 doesn't allow implicit relative imports.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • yeah I know its just that Stackoverflow doesn't allow to accept someone'e answer until 10 minutes is gone. – Souvik Ray Oct 15 '17 at 05:50
  • @SouvikRay I always forgot about that ;) – VonC Oct 15 '17 at 06:16
  • I am stuck in a new error of the same question.Think you can answer this? https://stackoverflow.com/questions/46752458/python-generates-systemerror-when-trying-to-import-a-module-into-another-module – Souvik Ray Oct 15 '17 at 06:57