开发者社区> 问答> 正文

python 在编译成EXE 文件后报错 我实在是找不出原因?报错

代码在本地的pycharm上是可以正常运行的,但通过 pyinstaller -F -w 转换成EXE后就报错了

然后我用 CMD 运行 提示说

然后我也按照网上说的 在第一行 添加字符转换  可还是不行,到底是那个地方出错了呢? 请教下大家

 

我付上源代码:

# -*- coding: utf-8 -*-
import wx
from win32con import AW_ACTIVATE, AW_BLEND, AW_CENTER, AW_HIDE, AW_HOR_NEGATIVE, \
    AW_HOR_POSITIVE, AW_SLIDE, AW_VER_NEGATIVE, AW_VER_POSITIVE, SPI_GETWORKAREA
import win32api
from ctypes import windll, c_int


class Popup(wx.MiniFrame):
    def __init__(self, label, parent=None, title=""):
        wx.MiniFrame.__init__(self, parent, -1, title, wx.DefaultPosition, size=(580, 280),
                              style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
        for monitor in win32api.EnumDisplayMonitors():
            monitor_info = win32api.GetMonitorInfo(monitor[0])
            if monitor_info['Flags'] == 1:
                break
        workarea = monitor_info['Work']

        pos = (workarea[2] - 580, workarea[3] - 280)
        bg = wx.Colour(255, 255, 225)
        self.SetBackgroundColour(bg)
        self.SetPosition(pos)
        text = wx.StaticText(self, -1, label)
        text.SetBackgroundColour(bg)
        flags = AW_SLIDE | AW_VER_NEGATIVE | AW_ACTIVATE
        windll.user32.AnimateWindow(c_int(self.GetHandle()), c_int(800), c_int(flags))
        self.Refresh()
        self.Bind(wx.EVT_CLOSE, self.RemovePopup)

    def RemovePopup(self, evt=None):
        flags = AW_BLEND | AW_HIDE
        windll.user32.AnimateWindow(c_int(self.GetHandle()), c_int(800), c_int(flags))
        self.Destroy()


if __name__ == '__main__':
    app = wx.App(False)
    f = Popup('测试右下角弹出框\n测试右下角弹出框\n\n')
    f.Show()
    app.MainLoop()

 

展开
收起
爱吃鱼的程序员 2020-06-05 14:54:59 520 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>两点可以试试:<br> 1.看着coding后面的冒号像是中文的,格式写对<br> 2.看看文件的编码格式是不是utf-8的</p>
                    
    
                            回复 <a class="referer" target="_blank">@阿有哥</a>  : 我不玩python,机子上没环境 你可以写个helloworld编译下,然后拷贝代码到可以编译的文件
                        
    
                            coding后面的冒号已经改为英文了,文件编码也确定是UTF-8的  依然还是不行,不知道那里错了,或者你能把这边代码复制到你的机子上 转换下EXE 看有没有出现和我一样的错误吗?
                        
    
                        <p>通过.spec文件打包试一下</p>
                    
    
                            tx是我要转成exe的源文件
                        
    
                            回复 <a class="referer" target="_blank">@阿有哥</a>  : tx是什么?是你引入的文件吗
                        
    
                            也还是一样 提示报错。
    
    2020-06-05 14:55:11
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载