cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Python Datalayer - Error importing ctrlxdatalayer

Bkrickl
Member

Python Datalayer - Error importing ctrlxdatalayer

Hi everyone,

we are trying to create a provider in python to share our data with the data layer. The problem is that I get an error when trying to import the datalayer.

import ctrlxdatalayer

throws the error:

Intel (QEMU):

Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctrlxdatalayer
System architecture:  x86_64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/boschrexroth/.virtualenvs/airtico-control-unit-backend/lib/python3.8/site-packages/ctrlxdatalayer/__init__.py", line 7, in <module>
    from ctrlxdatalayer import client, converter, factory, provider, provider_node, \
  File "/home/boschrexroth/.virtualenvs/airtico-control-unit-backend/lib/python3.8/site-packages/ctrlxdatalayer/client.py", line 9, in <module>
    import ctrlxdatalayer.clib
  File "/home/boschrexroth/.virtualenvs/airtico-control-unit-backend/lib/python3.8/site-packages/ctrlxdatalayer/clib.py", line 14, in <module>
    libcomm_datalayer = ctypes.CDLL("libcomm_datalayer.so")
  File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcomm_datalayer.so: cannot open shared object file: No such file or directory

 

Arm64 (Raspberry Pi):

Python 3.9.13 (main, May 23 2022, 21:57:12) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctrlxdatalayer
System architecture:  aarch64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/ctrlxdatalayer/__init__.py", line 7, in <module>
    from ctrlxdatalayer import client, converter, factory, provider, provider_node, \
  File "/usr/local/lib/python3.9/dist-packages/ctrlxdatalayer/client.py", line 9, in <module>
    import ctrlxdatalayer.clib
  File "/usr/local/lib/python3.9/dist-packages/ctrlxdatalayer/clib.py", line 14, in <module>
    libcomm_datalayer = ctypes.CDLL("libcomm_datalayer.so")
  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcrypto.so.1.1: cannot open shared object file: No such file or directory

 

We followed the tutorial to setup the development environment by installing all necessary libraries (https://github.com/boschrexroth/ctrlx-automation-sdk/blob/main/scripts/environment/cloud-config-amd6...) and the datalayer.deb. We also tried to QEMU environment from the repository with no success.

Are we missing something here?

Thank you

7 REPLIES 7
nickH
Occasional Contributor

Re: Python Datalayer - Error importing ctrlxdatalayer

Hi,

could you please explain, when exactly does your error occur? (when you pack your snap? when you run it on the ctrlX CORE? when you want to run it in your App Build Environment?)

Because you talked about setting up different development environemts: I would recommend to use the ctrlX WORKS integrated App Build Environment. It is the recommended way, because a special set of software is already downloaded and other dependencies, like the SDK itself can get downloaded easily with the help of installation scripts

One additional hint: some information about the Python samples included in the SDK can be found here

Best regards, 

Nick

Bkrickl
Member

Re: Python Datalayer - Error importing ctrlxdatalayer

Hey, thank you for your fast response.

The error occurs when we try to run our app in the development environment.

Thank you for your hints. We started to setup a dev environment manually because we don't use Windows computers and so the ctrlX Works software is not working for us. First we tried a solution by using a Raspberry Pi with Ubuntu 20 (Arm64) for development and for building our snaps. Everything worked fine until we wanted to include the datalayer in our application. 
Because that didn't work we setup a QEMU environment with the scripts provided in the ctrlx automation sdk folder but with the same result (like we shown in the error code snippets above)

Best regards, 

Benni

nickH
Occasional Contributor

Re: Python Datalayer - Error importing ctrlxdatalayer

Hi Benni, 

thanks for the details. To run python in your build environment you would need to set up a virtual python environment and install the packages libzmq5 and ctrlX Data Layer. A description can be found on PyPi.org.

You can take a look at the samples included in the SDK, how its done here. In every sample which uses the Data Layer we have a script called "install-venv.sh". If you execute this scipt it will create and activate a virtual Python environment for your project. It also installes all the requiered packages (in our samples they are defined in the "requirements.txt" file). Further a subfolder "venv/" will be created and activated as virtual environment which contains the Python runtime and all required packages. Please see the documentation on that here.

Best regards, 

Nick

Bkrickl
Member

Re: Python Datalayer - Error importing ctrlxdatalayer

We are already using a venv (in the QEMU setup) with no success. I also tried it on the Raspberry Pi with no success.

What we did:

  1. Setup a Raspberry Pi with Ubuntu Desktop 20 (Arm64)
  2. Manually creating all the scrtips for setting up the development environment from here:
    1. install-snapcraft.sh
    2. install-snapcraft.sh
    3. install-deb.sh (There is no install-deb configuration in the aarch64 setup, so we used it from the amd64 setup.
  3. Installing all required packages listed with apt here.
  4. Running the createt scripts in step 2
  5. Creating a venv as described here
  6. Installing all depedencies including the ctrlx-datalayer
  7. Starting the venv with the command 

 

source venv/bin/activate

 

  • Running the python interpreter with

 

python3​

 

  • Trying to import the ctrlx-datalayer with

 

import ctrlxdatalayer​

 

  •  Getting the error

 

Python 3.9.13 (main, May 23 2022, 21:57:12) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctrlxdatalayer
System architecture:  aarch64
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/ctrlxdatalayer/__init__.py", line 7, in <module>
    from ctrlxdatalayer import client, converter, factory, provider, provider_node, \
  File "/usr/local/lib/python3.9/dist-packages/ctrlxdatalayer/client.py", line 9, in <module>
    import ctrlxdatalayer.clib
  File "/usr/local/lib/python3.9/dist-packages/ctrlxdatalayer/clib.py", line 14, in <module>
    libcomm_datalayer = ctypes.CDLL("libcomm_datalayer.so")
  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcrypto.so.1.1: cannot open shared object file: No such file or directory​

 

I also checked teh GLIBCXX.

 

strings /usr/lib/aarch64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

 

with the response

 

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_3.4.30
GLIBCXX_DEBUG_MESSAGE_LENGTH

 

 

I am using a Arm64 architecture so the path to libstdc++.so.6 is differnt. 

I managed to get it run on my QEMU environment with amd64 architecture.I missed to step to install the datalayer dev here.

Is arm64 not supported for the datalayer in the development environment?

Best regards,

Benni

nickH
Occasional Contributor

Re: Python Datalayer - Error importing ctrlxdatalayer

Hi Benni,

Great, that you were able to run it with the QEMU (amd64) environment. 

Regarding your arm64 environment: could you check if you got the libcrypto.so.1.1? It should be located somewhere at "usr/lib/aarch64-linux-gnu". It seems to be missing, at least the error message says so. 

Best regards,

Nick

nickH
Occasional Contributor

Re: Python Datalayer - Error importing ctrlxdatalayer

Hi Benni, 

I just found time to test it on a Raspi (ubuntu 20 server). It worked for me. 

Are you sure you run it with python and the activated virtual environment. In my screenshot below you see the difference. If I run it with venv not activated, I get a similar error. (Please ignore the error I got, because no real ctrlX CORE was connected wit TCP). 

2022-08-12_09h31_33.png

 

Best regards, 

Nick

Bkrickl
Member

Re: Python Datalayer - Error importing ctrlxdatalayer

I reinstalled ubuntu server 20 on my pi and made the setup steps again. Now it is working (even without a venv).

Thank you for your help. I think i missed something in my first try but i don't know what.

 

Best regards,

Benni

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist