python3导入找不到modu

2024-10-01 00:27:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从一本书中测试一个例子,得到一个ImportError。在

这个例子的开头是:

from tkinter import *
from PP4E.Gui.Tools.widgets import frame, button, entry

如果我在代码的开头加一个import sys; print(sys.path),那么输出是

^{pr2}$

以下是我的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模块吗?谢谢。在


Tags: frompyimportinitsysguibuttonwidgets