P
P
Proritsatel2020-06-11 03:49:16
Python
Proritsatel, 2020-06-11 03:49:16

The .exe program does not work correctly after pyinstaller. How to find the problem?

Hello!
I wrote a program in pyCharm and it works great when run in pyCharm.
I decided to make an .exe file using pyinstaller , py2exe , auto_py_to_exe , cx_Freeze , I have an .exe file at the output that starts to work correctly, but in the end the program enters the except block. I also tried using other libraries to create .exe, cx_Freeze, auto-py-to-exe
Python 3.6 32-bit
I also created a *.pyc file, and if I run it, everything works fine.
The main code is larger, I will throw off the essence:

Подключаемся к ОРС:
import OpenOPC

opc = OpenOPC.client()
servers = opc.servers()
print(servers)
try:
    opc.connect(servers[0])
except:
    print("не удалось подключиться к ОРС - серверу")

while:
    try:
       #обрабатываем полученнные значения
    except:
        print("error read item")
        opc.close()

As I understand it, the problem is in the virtual environment, but in cmd.exe I installed all the necessary libraries as in the pycharm project.
This is how the OpcSender.py script works from the console or from pyCharm
5ee4cf446397e452835910.png
This is how OpcSender.exe works
5ee4d00c712e2569966194.png
What do you advise? thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Proritsatel, 2020-06-14
@Proritsatel

In general, how did you manage to solve the problem.
I created a new project in PyCharm and put there not all my 200 lines of code, but only the minimum necessary to test the program

import OpenOPC

opc = OpenOPC.client()
servers = opc.servers()
print(servers)
try:
    opc.connect(servers[0])
except:
    print("не удалось подключиться к ОРС - серверу")

while:
    try:
       #обрабатываем полученнные значения
    except:
        print("error read item")
        opc.close()

I assembled the program using pyinstaller, and then my console began to crash, ignoring the except block. As a result, I filmed a video on my phone, and in slow motion I saw an error
verbatim, I won’t give it, but the problem was with the win32timezone package.
Problem solution:
pyinstaller --hiddenimport win32timezone -F your_file.py
Helped me with this article https://stackoverflow.com/questions/33212949/import...

M
Morrowind, 2020-06-13
@hekkaaa

Hello, can I have screenshots of the errors?
Because the description of this is good, but in your case it is better to give screenshots.
The first thing that comes to mind until I see an error - and your system is x64 most likely. Maybe the problem lies in the different bitness of Python and OS? Because I don’t remember that pyinstaller had keys for bitness (maybe it’s worth checking).
Try installing x64 Python. Even though it seems like bullshit. Well, of course, screenshots in the studio with errors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question