Search code examples
pythonpippackageopcopc-ua

Python installing OPCUA package


Hey guys i have this problem:

I have to install OPCUA package for python. I have already installed opcua with pip install opcua. But I have this problem:

In my Python code: from opcua import Client,ua

i get this: Traceback (most recent call last): File "mytry.py", line 1, in from opcua import Client,ua ModuleNotFoundError: No module named 'opcua'

i tried to do this in the cmd and i thought i have to install crypthography so i wrote the command: pip install cryptography

But then i get this message: Command "python setup.py egg_info" failed with error code 1 in C:\Users\Mikail\AppData\Local\Temp\pip-install-h1su9k_x\cffi\

Can anyone help me? I am new in Python and OPCUA

Note: i have a windows 10 OS


Solution

  • Looks like you didn't install opcua correctly.

    Try to use pip list to check is it installed.

    You can get examples from https://github.com/FreeOpcUa/python-opcua, and go to examples folder.

    $ python server-minimal.py    
    

    Open another terminal

    $ python client-minimal.py
    
    Objects node is:  Node(TwoByteNodeId(i=84))
    Children of root are:  [Node(NumericNodeId(i=85)), Node(NumericNodeId(i=86)), 
    Node(NumericNodeId(i=87))]
    myvar is:  Node(NumericNodeId(ns=2;i=2))
    myobj is:  Node(NumericNodeId(ns=2;i=1))
    

    crypthography is just for security, it's not necessary to install.

    If crypthography is not installed, you will get a message,

    cryptography is not installed, use of crypto disabled