Reputation: 97
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
Upvotes: 1
Views: 11257
Reputation: 81
This could be due to module being not installed properly or the installed Python package is an older version. Check if the opcua module is installed using
pip list
If the problem persists, then try updating the Python package (Python version > 3.4), else try using pip3 instead of pip.
Since the python-opcua library is in maintenance mode, you can try out the examples available in opcua-asyncio which is the fork of python-opcua: https://github.com/FreeOpcUa/opcua-asyncio/tree/master/examples
You can refer to the documentation available here: https://opcua-asyncio.readthedocs.io/en/latest/
You can also try out these open source OPC UA implementations that you might find interesting:
If you are looking for more hands-on information (it uses another open source stack) , you can also check out these resources:
Upvotes: 3
Reputation: 3378
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
Upvotes: 1