[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Import module from a different subdirectory

On Thu, 16 May 2019, Rich Shepard wrote:

> The project directory contains subdirectories, including gui/ (with the
> tkinter views) and classes/ with the SQLAlchemy model.py.

Getting closer, but still missing a piece of the solution.

First, I added __init__.py to each module subdirectory to specify that the
subdirectory is a package.

Second, in ~/.bash_profile I added two lines, the first is the project's
root directory:


Testing this suggests that python is finding the path:

$ 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 os
>>> os.environ["PYTHONPATH"]

but the import is still not working.

Do I need to specify each bustrac/ subdirectory in the PYTHONPATH? If not,
what am I still missing?