Import module from a different subdirectory

Piet van Oostrum piet-l at
Sat May 18 18:20:55 EDT 2019

Rich Shepard <rshepard at> writes:

> $ python3
> Python 3.7.3 (default, Mar 26 2019, 06:40:28) [GCC 5.5.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> sys.path
> ['', '/home/rshepard/development/bustrac', '/usr/lib/',
> '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload',
> '/usr/lib/python3.7/site-packages']
> When the gui/ subdirectory is the current working directory and I try to run
> I get the error that is not found in the classes
> subdirectory. I don't see how my directory structure, file locations, and
> paths differ from your examples.

In a previous message the error was that 'classes' wasn't found, not that wasn't found in classes, i.e. it was the same error as Peter got.

So to get this working you must make sure 'classes' is inside a directory that is in sys.path, for example by adding:

sys.path.insert(0, '..')
Piet van Oostrum <piet-l at>
PGP key: [8DAE142BE17999C4]

More information about the Python-list mailing list