AttributeError:通过Pyinstaller将python脚本转换为EXE之后 [英] AttributeError: After converting python script to EXE by Pyinstaller

查看:263
本文介绍了AttributeError:通过Pyinstaller将python脚本转换为EXE之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于计算目的,我制作了一个python脚本,导入了库,Tkinter,Pmw,sympy,数学,tkfile对话框,Web浏览器.

I have made a python script for calculations purposes, importing libraries, Tkinter, Pmw, sympy, math, tkfiledialog, webbrowser.

现在,通过使用Pyinstaller,我将其转换为EXE应用程序. 当我运行它时,它会显示错误:

Now, by using Pyinstaller I convert it into an EXE application. When I run it, it gives the error:

WindowsError: [Error 3] The system cannot find the path specified: 'C:\\Python27\\Earthing\\dist\\Earthing\\Pmw/*.*'

因此,我将整个 Pmw 目录复制并粘贴到此位置.但是,这样做之后,我得到了错误:

So, I copy and paste the entire Pmw directory on this location. However, after doing this, I get the error:

AttributeError: 'module' object has no attribute 'OptionMenu'

现在,如何解决此错误?请帮我解决这个问题.

Now, how do I resolve this error? Please do help me sort this out.

推荐答案

我遇到了同样的问题.这是由于我所说的动态导入",主要是在PmwLoader.py(放置在lib子文件夹中)进行的:PmwLoader加载所有文件,它们成为Pmw全局库的属性.

I ran into the same problem. It is due to what I would call 'dynamic imports', made mostly in PmwLoader.py (placed in lib subfolder): PmwLoader loads all the files, and the they become attributes of Pmw global library.

我找到的解决方案是在所有需要的Pmw文件中手动删除"import Pmw"行(我仅使用PmwComboBox和PmwScrolledFrame). PmwCombobox和PmwScrolledFrame特别需要导入其他Pmw文件,因此我不得不替换 导入Pmw 通过

The solution I found was to manually delete the line 'import Pmw' in all the wanted Pmw files (I only used PmwComboBox and PmwScrolledFrame). PmwCombobox and PmwScrolledFrame notably need to import other Pmw files, so I had to replace import Pmw by

import PmwBase
import PmwScrolledListBox
import PmwEntryField
import PmwTimeFuncs

,然后在PmwScrolledListBox和PmwEntryFiled中执行相同的操作.

and then do the same in PmwScrolledListBox and PmwEntryFiled.

有趣的是解决了这些错误-尤其是用PmwBase.MegaWidget替换了很多MegaWidget,等等.

The the fun is to solve the bugs --notably replace a lot of the MegaWidget by PmwBase.MegaWidget, and so on.

最后,不超过一小时.

祝你好运! t.

这篇关于AttributeError:通过Pyinstaller将python脚本转换为EXE之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆