I have a problem very similar to this one. I too am working from Programming Python 4th edition. I am using a mac powerbook. I have a directory structure similar to:
programming\ python
├── PP4E
│ ├── GUI
│ │ ├── Tour
│ │ │ ├── __init__.py
│ │ │ ├── demoAll-prg.py
│ │ │ ├── demoAll-win.py
│ │ │ ├── demoCheck.py
│ │ │ ├── demoDlg.py
│ │ │ ├── demoRadio.py
│ │ │ ├── demoScale.py
│ │ ├── __init__.py
│ ├── __init__.py
│ └── launchmodes.py
└── __init__.py
The demoAll-prg.py tries from PP4E.launchmodes import PortableLauncher
, but returns ImportError: No module named 'PP4E'
.
Answers on SO generally say to make sure the folders have __init__.py files present (done!), and/or to add the parent directory (here, "programming python") to PYTHONPATH. This also agrees with Learning Python, 5th ed., p. 709.
I tried a few different ways of editing my python path, such as described here, to no avail. Currently my .bash_profile has this added to the end:
PYTHONPATH=“/Users/geoffreysametz/google drive/programming python”
export PYTHONPATH
but this is not solving the issue. I have closed and reopened the terminal, and have rebooted the computer.
Any advice on how to fix this problem is greatly appreciated.