python - 通过双击运行 .py 不起作用

标签 python

我使用的是 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/

相关文章:

python - Fabric 导入错误 : cannot import name 'isMappingType'

python - 如何在 Flask-login 中调用 is_authenticated

Python 日志记录重复

python - Pandas 滚动窗口函数偏移数据

python - 属性错误 : 'RandomForestClassifier' object has no attribute 'fit_transform'

python - tf.contrib.learn.LinearRegressor 的拟合函数要求切换到 tf.train.get_global_step

python - Python 的递归限制?

python - Pandas applymap内存错误

python - 使用 SleekXMPP 连接到 Facebook 聊天

python - 如何使用 celery 使用 mongoengine 向 mongodb 插入数据