Как исправить ошибку после создания exe с помощью Pyinsaller?

#python-3.x #pyinstaller #ibm-mq #pymqi

Вопрос:

После создания 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') 
 

Комментарии:

1. Установлены ли у вас клиентские библиотеки mq, в которых вы пытаетесь запустить exe-файл?

2. @JoshMc, Какие библиотеки вы имеете в виду?

3. libmqm.so например.