Import module from a different subdirectory
Piet van Oostrum
piet-l at vanoostrum.org
Sat May 18 18:20:55 EDT 2019
Rich Shepard <rshepard at appl-ecosys.com> 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
> ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip',
> '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload',
> When the gui/ subdirectory is the current working directory and I try to run
> text_act_de.py I get the error that model.py 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 model.py 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:
Piet van Oostrum <piet-l at vanoostrum.org>
PGP key: [8DAE142BE17999C4]
More information about the Python-list