Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

I have a file called, located on /project.

/project has a subdirectory called lib, with a file called



I want to import BoxTime from the tester. I have tried this:

import lib.BoxTime

Which resulted:

Traceback (most recent call last):

File "./", line 3, in <module>

import lib.BoxTime

ImportError: No module named lib.BoxTime

Any ideas on how to import BoxTime from the subdirectory?

1 Answer

0 votes
by (106k points)

To import a file from a subdirectory, you just need to put a blank file in the "lib" directory named as and it will do all the work for you:-

If you want to import files using Python code then you need to write the following piece of code:-

from lib import BoxTime

Related questions

0 votes
2 answers
asked Oct 3, 2019 in Python by Tech4ever (20.3k points)
0 votes
2 answers
0 votes
1 answer
asked Jan 7, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

29.3k questions

30.6k answers


104k users

Browse Categories