如何修复使用 Pyinsaller 创建 exe 后的错误?

问题描述 投票:0回答:1

创建exe文件后,出现如下错误。

此问题可能与TCP/IP协议有关。

我不太明白错误是什么。

Traceback (most recent call last):
  File "list_queue.py", line 56, in <module>
  File "list_queue.py", line 17, in lenth_queue
  File "pymqi\__init__.py", line 3024, in connect
  File "pymqi\__init__.py", line 1649, in connect_tcp_client
  File "pymqi\__init__.py", line 1624, in connect_with_options
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2012: FAILED: MQRC_ENVIRONMENT_ERROR

虽然 PyCharm 中一切正常,但我输入的所有数据都有效,并且脚本也正常工作。 我的代码:

def lenth_queue():
    
    dict_queue = collections.defaultdict(dict)
    queue_manager = input('Enter the name of the queue manager: ')
    channel = input('Enter the name of the communication channel: ')
    host = input('Enter a name for the IP address of the queue manager: ')
    port = input('Enter the name of the queue manager port: ')
    conn_info = '%s(%s)' % (host, port)
    queue_type = pymqi.CMQC.MQQT_LOCAL
    qmgr = pymqi.connect(queue_manager, channel, conn_info)
    c = 0
    try:
        prefix = '*'
        pcf = pymqi.PCFExecute(qmgr,response_wait_interval=600000)
        attrs = []  # typeList[pymqi.MQOpts]
        attrs.append(pymqi.CFST(Parameter=pymqi.CMQC.MQCA_Q_NAME,
                                    String=pymqi.ensure_bytes(prefix)))
        attrs.append(pymqi.CFIN(Parameter=pymqi.CMQC.MQIA_Q_TYPE,
                                    Value=queue_type))
        attrs.append(pymqi.CFIL(Parameter=pymqi.CMQCFC.MQIACF_Q_ATTRS,
                                    Values=[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]))

        object_filters = []
        object_filters.append(
                    pymqi.CFIF(Parameter=pymqi.CMQC.MQIA_CURRENT_Q_DEPTH,
                               Operator=pymqi.CMQCFC.MQCFOP_GREATER,
                               FilterValue=0))

        response = pcf.MQCMD_INQUIRE_Q(attrs, object_filters)

        for queue_info in response:
            queue_name = queue_info[pymqi.CMQC.MQCA_Q_NAME]
            queue_depth = queue_info[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]
            dict_queue[queue_name.strip().decode()] = queue_depth
            c += 1
        writer_queue('Queue_lenth',dict_queue)
        return 'File written successfully'
    except pymqi.MQMIError as e:
        return 'Failed to connect'
        


def writer_queue(name,dict_q):
        txt = io.open(name + ".txt", "w", encoding="utf-8")
        for key in dict_q:
            txt.write('{}: {} message(s)'.format(key, dict_q[key]) + '\n')
        txt.close()

print(lenth_queue())
input('Press ENTER to exit') 
python-3.x pyinstaller ibm-mq pymqi
1个回答
0
投票

使用 py2exe 后我遇到了同样的问题。 尝试在我的原始 Python 代码(由 py2exe 用于创建 .exe 文件)运行的同一台计算机上运行,没有问题。

© www.soinside.com 2019 - 2024. All rights reserved.