我使用的是 Windows XP。
当我双击《Python 编程》一书中的 Launch_PyDemos.pyw 时,没有任何反应。当我尝试从命令行运行 Launch_PyDemos.pyw 时,收到错误消息:
Traceback (most recent call last):
File "PyDemos2.pyw", line 41, in <module>
from PP3E.Gui.Tools.windows import MainWindow # a Tk with icon, title, quit
ImportError: No module named PP3E.Gui.Tools.windows
当我将 PythonPath 环境变量设置为 PP3E 文件夹时,没有任何反应。当我将 PP3E 文件夹附加到 Path 环境变量时,没有任何反应。当我将 PP3E 目录树复制到 Python 源库中的 site-packages 文件夹时,没有任何反应。
这是怎么回事?
最佳答案
您缺少书中的库。引用a bytes thread :
Please follow the instructions on the book, or read the README-PP3E.txt file; below I copy the most relevant parts:
"""Copy the entire PP3E directory tree to some directory on your computer, and add the name of the directory containing PP3E to your module search path (i.e., you PYTHONPATH shell setting, ".pth" files, etc.).
Alternatively, copy the PP3E directory tree to the site-packages folder in your Python source library (e.g., C:\Python24\Lib\site-packages on Windows for Python 2.4). Because this directory is automatically searched on imports, copying here makes PYTHONPATH settings unnecessary."""
Also, make sure you get the updated version from http://examples.oreilly.com/python3/pp3e-updates.html
关于python - 通过双击运行 .py 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2310189/