First time here? Check out the FAQ!
x

OpenOPC script execute with PyInstaller

0 votes
asked by about OpenOPC for Python
edited by

How can I execute OpenOPC with pyinstaller? When I'm trying to run the .exe file I have this error:

starting connection...
Traceback (most recent call last):
  File "<string>", line 20, in onToggle
  File "OpenOPC.py", line 170, in __init__
  File "site-packages\win32com\client\gencache.py", line 540, in EnsureDispatch
  File "site-packages\win32com\client\gencache.py", line 524, in EnsureModule
  File "site-packages\win32com\client\gencache.py", line 291, in MakeModuleForTy
pelib
  File "site-packages\win32com\client\makepy.py", line 286, in GenerateFromTypeL
ibSpec
  File "site-packages\win32com\client\gencache.py", line 554, in AddModuleToCach
e
  File "site-packages\win32com\client\gencache.py", line 633, in _GetModule
  File "c:\users\ibm-3\appdata\local\temp\tmp4npxxv\gen_py\341A7851-5DEA-4022-B0
D6-F9954AF9273Dx0x1x0.py", line 10, in <module>
    import win32com.client.CLSIDToClass, pythoncom, pywintypes
  File "C:\PyInstaller-3.1.1\PyInstaller\loader\pyimod03_importers.py", line 158
, in load_module
    return self._importer.load_module(fullname, self._fullname)
  File "C:\PyInstaller-3.1.1\PyInstaller\loader\pyimod03_importers.py", line 389
, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\pythoncom.py", line 2, in <module>
  File "C:\PyInstaller-3.1.1\PyInstaller\loader\pyimod03_importers.py", line 158
, in load_module
    return self._importer.load_module(fullname, self._fullname)
  File "C:\PyInstaller-3.1.1\PyInstaller\loader\pyimod03_importers.py", line 389
, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\win32\lib\pywintypes.py", line 2, in <module>
  File "C:\PyInstaller-3.1.1\PyInstaller\loader\pyimod03_importers.py", line 158
, in load_module
    return self._importer.load_module(fullname, self._fullname)
  File "C:\PyInstaller-3.1.1\PyInstaller\loader\pyimod03_importers.py", line 389
, in load_module
    exec(bytecode, module.__dict__)
  File "os.py", line 120, in <module>
ImportError: No module named path

I use pyinstaller 3.1.1, python 2.7.12, OpenOPC 1.3.1

pyinstaller syntax:
pyinstaller.py --onefile toggle_button_openopc.py 

and my script:
import wx
import OpenOPC

class MyForm(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, "OpenOPC", 
                                   size=(500,500))
        panel = wx.Panel(self, wx.ID_ANY)
        self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Connect")
        self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle)

    def onToggle(self, event):
        btnLabel = self.toggleBtn.GetLabel()
        if btnLabel == "Connect":
            self.toggleBtn.SetLabel("Disconnect")
            print "starting connection..."
            PLC = OpenOPC.client()
            PLC.connect('CoDeSys.OPC.02')
        else:
            print "stop connection..."
            self.toggleBtn.SetLabel("Connect")

if __name__ == "__main__":
    app = wx.App()
    frame = MyForm().Show()
    app.MainLoop()

1 Answer

0 votes
answered by (309k points)

Since there is no information related to this procedure, I recommend contacting the developer at the following email address to request some details on how to properly use the application.

  • Email contact: barry_b@users.sourceforge.net

Additionally, you can visit the following page to learn more about the OpenOPC software: http://openopc.sourceforge.net/api.html

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...