我正试图从一本书中测试一个例子,我得到一个ImportError
。
示例从:
开始from tkinter import *
from PP4E.Gui.Tools.widgets import frame, button, entry
如果我在代码的开头加上import sys; print(sys.path)
,则输出为
['/Users/aaa/Documents/workspace/programming-python/PP4E/Lang/Calculator',
'/usr/local/lib/python3.4/site-packages/setuptools-12.2-py3.4.egg',
'/usr/local/lib/python3.4/site-packages/pip-6.0.8-py3.4.egg',
'/User/aaa/Documents/workspace/programming-python',... ]
这是我的programming-python
目录的截断版本:
❯ tree
.
├── PP4E
│ ├── __init__.py
│ ├── Gui
│ │ ├── Tools
│ │ │ ├── __init__.py
│ │ │ └── widgets.py
│ │ └── __init__.py
│ ├── Lang
│ │ └── Calculator
│ │ ├── __init__.py
│ │ └── calc0.py
└── site-packages
└── PP4E.pth
我收到的错误消息是:
❯ python3 calc0.py
Traceback (most recent call last):
File "calc0.py", line 2, in <module>
from PP4E.Gui.Tools.widgets import frame, button, entry
ImportError: No module named 'PP4E'
有人知道我要做什么才能让Python找到PP4E模块吗?感谢。
答案 0 :(得分:4)
I had my [root@death public_html]# ls -la test.*
-r-xr-xr-x. 1 infinitywhack www 342 May 12 23:36 test.php
-rwxrwxrwx. 1 infinitywhack www 5 May 12 23:06 test.txt
wrong -- the root directory is PYTHONPATH
, not /Users
. Thanks.