Re: Import module from a different subdirectory

2019-05-19 Thread Peter J. Holzer
On 2019-05-18 16:15:34 -0700, Rich Shepard wrote: > My apologies to all who patiently tried to get me to see what I kept > missing. I've certainly made similar mistakes in the past (and probably will in the future). And I didn't see it when I read your mail the first time. But then I read Piet's

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sun, 19 May 2019, Peter J. Holzer wrote: This won't help much if your directory named "business-tracker" (see above). Peter, et al.: Yep. User error. The directory is actually 'business_tracker' and I used the application name, 'bustrac', instead when I set PYTHONPATH. Discovered this a bi

Re: Import module from a different subdirectory

2019-05-18 Thread Peter J. Holzer
On 2019-05-18 09:43:34 -0700, Rich Shepard wrote: > The project layout, briefly, is: > > ~/development/business-tracker/ > classes/ > gui/ > > All subdirectories contain a __init__.py file to identify them as packages. > 'classes/' contains model.py; '

Re: Import module from a different subdirectory

2019-05-18 Thread Piet van Oostrum
Rich Shepard 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/python37.zip', > '/usr/lib/python3.

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sat, 18 May 2019, Peter J. Holzer wrote: "" is in sys.path, so "classes" and classes.model are found. Now lets go to a different subdirectory: This doesn't work, since there is no classes/model.py in "", only in "..". But if I add a PYTHONPATH, it works again: Peter, The project layout,

Re: Import module from a different subdirectory

2019-05-18 Thread Peter J. Holzer
On 2019-05-18 05:45:23 -0700, Rich Shepard wrote: > On Sat, 18 May 2019, dieter wrote: > > > > sys.path > ['', '/home/rshepard/development/bustrac', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', > '/usr/lib/python3.7/site-packages'] > > All directories are pres

Re: Import module from a different subdirectory

2019-05-18 Thread Rich Shepard
On Sat, 18 May 2019, dieter wrote: Test this by looking at "sys.path" instead: import sys sys.path It is "sys.path" which actually controls the import machinery. Dieter, Thank you. I missed this when researching PYTHONPATH. Here's what I get: sys.path ['', '/home/rshepard/development/bus

Re: Import module from a different subdirectory

2019-05-17 Thread dieter
Rich Shepard writes: >> The project directory contains subdirectories, including gui/ (with the >> tkinter views) and classes/ with the SQLAlchemy model.py. > ... > Second, in ~/.bash_profile I added two lines, the first is the project's > root directory: > > PYTHONPATH=$HOME/development/bustrac >

Re: Import module from a different subdirectory

2019-05-17 Thread Rich Shepard
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 speci

Re: Import module from a different subdirectory

2019-05-17 Thread Rich Shepard
On Fri, 17 May 2019, Inada Naoki wrote: This is slightly off topic (not relating to your problem), but please don't think "Python 3 doesn't require __init__.py for packages". It is common misunderstanding. Inada, Actually, your response is on topic and probably the reason I have the import pr

Re: Import module from a different subdirectory

2019-05-16 Thread Inada Naoki
2019年5月17日(金) 9:25 Rich Shepard : > > My understanding is that Python3 does not require subdirectories to have an > __init__.py file, only Python2 does. If that's not correct I'll add the > blank file. > This is slightly off topic (not relating to your problem), but please don't think "Python 3 do

Re: Import module from a different subdirectory

2019-05-16 Thread dieter
Rich Shepard writes: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within the gui/ directory as

Re: Import module from a different subdirectory

2019-05-16 Thread Rich Shepard
On Fri, 17 May 2019, duncan smith wrote: You could make the subdirectories Python packages. Google (or better DuckDuckGo) is your friend. Duncan, My understanding is that Python3 does not require subdirectories to have an __init__.py file, only Python2 does. If that's not correct I'll add the

Re: Import module from a different subdirectory

2019-05-16 Thread duncan smith
On 16/05/2019 22:50, Rich Shepard wrote: > I'm developing a Python3 application using Python3-3.7.3 and > virtualenv-16.5.0 on a Slackware-14.2 host. > > The project directory contains subdirectories, including gui/ (with the > tkinter views) and classes/ with the SQLAlchemy model.py. > > Within

Import module from a different subdirectory

2019-05-16 Thread Rich Shepard
I'm developing a Python3 application using Python3-3.7.3 and virtualenv-16.5.0 on a Slackware-14.2 host. The project directory contains subdirectories, including gui/ (with the tkinter views) and classes/ with the SQLAlchemy model.py. Within the gui/ directory as the cwd testing the code for a v