zoukankan      html  css  js  c++  java
  • python 打包好后出现 failed to execute script问题

    我有个很不好的习惯,就是喜欢直接在class下面直接写class的测试用的代码, 比如这种:

    class SVN():
        def __init__(self):
            self.setting = {
                'svn':'C:/Program Files/TortoiseSVN/bin/',  # svn的程序所在路径
                'url':'',  # svn地址
                'user':'',
                'pwd':'',
                'dist':'D:/SVN_Block/Version1/SampleProject/',  # 目标地址
                'interval': 15,  # 更新时间
                'num':5
                }
    
            self.project_url = {
                            'pre7_419':'',
                            'pre7_424':'',
                            'post7_424':''
                            }
    
        def set_user(self, string):
            self.setting['user']=string
    
        def exec_cmd(self, username=''):
    
            # pprint.pprint(time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime()))
            # cmd='svn update %(url)s %(dist)s --username %(user)s'%setting  #export, dont use it
            # cmd = 'svn update %(dist)s --username %(user)s' % setting   #update svn
            line = 3
            if(username ==''):
    
                cmd = 'svn log %(url)s -l %(num)s' % self.setting
    
            else:
                cmd ='svn log %(url)s --search %(user)s -l %(num)s' % self.setting
    
            result = "execute %s" % cmd
            # print (result)
    
            return cmd
    
        def get_cmd_result(self, cmd):
            r = os.popen(cmd)
            text = r.read()
            r.close()
            return text
    
    client = util.get_client(r'D:SVN_BlockVersion1SampleProject')
    info = client.info()
    
    remote_client = remote.RemoteClient(r'file:///H:/SVNHook/branches/Version1/SampleProject')
    
    r_info = remote_client.info()
    r_log = remote_client.log_default()
    for i in r_log:
        print (i)

    然后到最后打包的时候虽然class外的代码没有使用到,但是编译器会不管三七二十一编译一遍,程序在我电脑上运行是不会出错的,但在同事电脑上就不行了, 原因是因为, 注意这里有个remoteClient和get_client用的路径是绝对路径。虽然没有在UI里执行但是会编译,所以会直接报错.

    如果程序里真的有绝对路径但是又不知道在哪的话可以在打包的时候用--debug=all来看运行过程(打包我用的是PyInstaller)

  • 相关阅读:
    用goto做异常处理
    零长度数组的妙用
    DTMF三种模式(SIPINFO,RFC2833,INBAND)
    Myeclipse下的struts2.3.8 配置 保证绝对好用
    Linux内核--内核数据类型
    Linux内核:kthread_create(线程)、SLEEP_MILLI_SEC
    3.4.4 数据预留和对齐(skb_reserve, skb_push, skb_put, skb_pull)
    Linux 2.6内核中新的锁机制--RCU
    Linux中SysRq的使用(魔术键)
    CentOS Linux服务器安全设置
  • 原文地址:https://www.cnblogs.com/sunchuankai/p/14174261.html
Copyright © 2011-2022 走看看