Menu

OpenOPC Python Client on Linux

Markus
2011-11-15
2016-02-12
  • Markus

    Markus - 2011-11-15

    Hallo!

    I'm trying to install and use OpenOPC with Python on Debian.
    Maybe I'm doing something wrong. I get always the following error:

    Traceback (most recent call last):
      File "test.py", line 2, in <module>
        opc = OpenOPC.client()
      File "/home/gorgemann/OpenOPC-1.1.6/src/OpenOPC.py", line 167, in __init__
        except pythoncom.com_error, err:
    NameError: global name 'pythoncom' is not defined

    pythoncom isn't available for Debian.
    Any idea what I can do?

    regards
    Markus

     
  • SpinelliCreations

    sir, the code chunk where line 167 results in an exception is calling "win32com.client.gencache.EnsureDispatch(c, 0)".

    as you can see… there's a direct reference to the the "win32com.client" library, which is a WINDOWS ONLY library for python.

    from the looks of it, that is the section which lists the available opc class (server types) on the machine via os-specific defined environment variables.

    long story short - that 'chunk' of code should never be run on a linux box. 

    the open opc gateway service should be run on a windows server (or a virtual machine inside a linux host), and the open opc client can then 'talk' to the gateway from the linux world. 

     
  • Barry Barnreiter

    On Linux you should be doing this….

    opc = OpenOPC.open_client(host)

    Where "host" is the name or IP address of your box running the OpenOPC Gateway Service.

    As Vince said, OpenOPC.client() should never be called on a non-Windows box.

     
  • Daniel Alvarez

    Daniel Alvarez - 2015-04-27

    Hello

    I recently found OPenOPC and have begun building a project.
    my server has been installed, and tested out fine, it is WinXP
    I have now begun building out the client on Linux Ubuntu and have encountered
    this error in the PyCharm- ide.
    Has anyone encountered this error (below) while trying to connected to the server

    Current Script:

    !/usr/bin/python

    import OpenOPC
    opc = OpenOPC.open_client('192.168.2.21')
    opc.servers()

    Error:

    Traceback (most recent call last):
    File "/home/dalvarez/PycharmProjects/TrainProj/Openopc.py", line 30, in <module>
    opc = OpenOPC.open_client('192.168.2.21')
    File "/usr/lib/python2.7/OpenOPC.py", line 129, in open_client
    return server_obj.create_client()
    File "/usr/lib/pymodules/python2.7/Pyro/core.py", line 381, in call
    return self.send(self.name, args, kwargs)
    File "/usr/lib/pymodules/python2.7/Pyro/core.py", line 455, in _invokePYRO
    self.adapter.bindToURI(self.URI)
    File "/usr/lib/pymodules/python2.7/Pyro/protocol.py", line 290, in bindToURI
    raise ProtocolError('connection failed')
    Pyro.errors.ProtocolError: connection failed

    Any advise would be very appreciated.

     
  • Ivan

    Ivan - 2016-02-12

    I resolved this problem by uninstalling python 2.7 (which was installed only for the user profile) and re-installing it for all users.

     

Log in to post a comment.