本文介绍了AttributeError: 'module' 对象在 wxPython 中没有属性 'PyScrolledWindow'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 python 版本是 2.7,python 32 位 2.7 版本的 wxPython 版本是 3.0.我目前正在使用 wxPython 开发一个 GUI 应用程序.我测试了我的代码它工作正常,我暂停了我的工作以保存我的文件.我开始在我的机器上安装一些软件.然后当我再次开始使用 wxPython 继续我的工作时,我突然开始收到错误消息.下面给出了完整的错误.我不明白原因.我也没有编辑我的代码.但是我可以执行我的其他 python 程序.

My python version is 2.7 and wxPython ver 3.0 for python 32 bit 2.7 version. I was currently working on a GUI app with wxPython. I tested my code it was working fine, I paused my work saved my files. I started to install some software on my machine. Then when I again started to continue my work with wxPython suddenly I started to receive an error. The complete error is given below. I don't understand the reason. I didn't edit my code too. However I am able to execute my other python programmes.

错误:

File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\lib\scrolledpanel.py", line 21, in <module>
    class ScrolledPanel( wx.PyScrolledWindow ):
AttributeError: 'module' object has no attribute 'PyScrolledWindow'

我重新安装了 wxPython 但没有任何改变.我尝试使用谷歌进行调查.但一切都是徒劳的.有人可以就此给我一些建议吗?

I reinstalled wxPython but nothing changed. I tried to investigate using google. But all in vain. Can some provide me some advice on this?

python 代码有以下导入语句:

The python code has following import statements:

import wx
import wx.lib.scrolledpanel

我使用这样的导入:

panel = wx.lib.scrolledpanel.ScrolledPanel(self, -1, size=(1000,500), pos=(0,50), style=wx.SIMPLE_BORDER)

感谢您的时间.

推荐答案

根据我们的聊天记录:您的项目文件位于桌面上.您的桌面上可能还有更多 .py 文件.其中一些隐藏了您导入的库名称,可能类似于 wx.py.因此,您不是导入 wx 库,而是导入其他内容,即不需要的内容.

As per our chat: You have your project files located on Desktop. There are probably many more .py files on your desktop. Some of them shadow your imported library name, maybe something like wx.py. So instead of importing wx library, you import something else, what does not have needed contents.

尝试在更可控的环境中运行您的代码,例如为您的项目创建一个目录,仔细检查该目录中的文件名和您的 Python 路径以获取阴影名称.它应该可以工作.

Try running your code in a more controlled environment, e.g. create a directory for your project, double check file names in that directory and your Python path for shadowing names. It should work.

这篇关于AttributeError: 'module' 对象在 wxPython 中没有属性 'PyScrolledWindow'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 14:22