【发布时间】:2016-08-09 14:16:10
【问题描述】:
我有一个与this one 非常相似的问题。我也在使用Programming Python 4th edition。我正在使用mac powerbook。我的目录结构类似于:
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
demoAll-prg.py 尝试from PP4E.launchmodes import PortableLauncher,但返回ImportError: No module named 'PP4E'。
关于 SO 的答案通常是确保文件夹存在 __init__.py 文件(完成!),和/或将父目录(此处为“编程 python”)添加到 PYTHONPATH。这也与 Learning Python, 5th ed., p. 一致。 709.
我尝试了几种不同的方法来编辑我的 python 路径,例如here 中的描述,但无济于事。目前我的 .bash_profile 已将其添加到末尾:
PYTHONPATH=“/Users/geoffreysametz/google drive/programming python”
export PYTHONPATH
但这并不能解决问题。我已经关闭并重新打开了终端,并重新启动了计算机。
非常感谢任何有关如何解决此问题的建议。
【问题讨论】:
标签: macos python-3.x pythonpath