Dear Community User! We are updating our platform to a new system.
Read more: Important information on the platform change.

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

ModuleNotFoundError when using import datalayer

ModuleNotFoundError when using import datalayer

ugy1sgh1
New Poster

Hello, colleague;

I am very intereasting in python with ctrlX. I have already installed the python app in my virtual controller.

some guys show me a example write by python,

the first line is " import Datalayer"

when I try to import Datalayer, it will throw out "ModuleNotFoundError".

Is this module have already installed in the Virtal control?  Or should I do something special seeting?

Thank you very much!python_no_module.png

 

9 REPLIES 9

redford
Long-established Member

Hello, is there any update about this problem? I got also the same error.

Thanks.

python error.png

 

CodeShepherd
Community Moderator
Community Moderator

Actually it is only possible to have access to the ctrlX Data Layer and the ctrlX MOTION via using the our integrated python interpreter. The interface to the firmware is fix connected to this app so there is no shared library that can be used via import.
You have to handle over complete .py files to it at start them. Other possibility would be to use the REST API out of your code to interact with our system. There all data and motion functions can be used.

When I get it right you set up your own app with your own python interpreter. There is at the moment no wheel or or other extensions for this case. This is planned to be provided with the March release RM21.03 (version 1.8) of the SDK.

 

Good morning,

I am using a script that writes a value, via datalayer, it works correctly if I load and start it via REST API, following this instructions.

Now, I'm trying to use Tiger IDE, but I can't import datalayer script. I guess it is due to the python interpreter, what is the interpreter path?  can I change it?

asanchez_lsa_2-1618567681524.png

I am working with the following versions:

  • ctrlX - 1.6.0
  • PythonRuntime - 1.6.0
  • Tiger 0.0.207

 

Thanks in advance.

Please first of all update your system to the release RM21.03 version (1.8) and also use the first official release 1.8 of the IDE app (former known as TIGER). The older version are prototypes including some known issues.

Further more there are two ways of running a script in the textual coding editor in the IDE app:

1) Run the script directly in the browser:

  • The signatures of the system functions are available and can be imported for programming purposes, like syntax highlighting and auto completion.
  • CodeShepherd_1-1618816041454.png

  • The interpreter integrated in the IDE app is used.
    CodeShepherd_0-1618815879392.png

  • But the functions that should be called by the signatures are not available so this cannot run at the moment.

2) Run the script on the ctrlX CORE:

  • The signatures of the system functions are available and can be imported for programming purposes, like syntax highlighting and auto completion. Like above.

  • The interpreter of the python runtime on the ctrlX CORE is used.
    CodeShepherd_3-1618817123401.png

     

  • Here the functions used in the code are part of and known by the python runtime in the system. So the import lines should be commented.
    CodeShepherd_6-1618817297059.png

P.S.: The link in your post isn't working.

Hi, I am getting the same error "ModuleNotFoundError: No module named 'ctrlxpy'". I am trying to read the status of input on Channel 1 of my input module. Please tell me what I am doing wrong. Attaching some screenshots for reference:

IDE version: 1.12.7
 
thegeterrdone_0-1660066253606.png

 

thegeterrdone_1-1660066329606.png

 

 Thanks for your help 🙂

 

 

Please check post above. This library is for auto completion only at the moment and the function cannot be used. Please execute the script on the control and comment this line to get it to work.

Thanks for the answer, but I already tried that I get the following error:

datalayer is not defined. 

thegeterrdone_0-1660120556207.png

Can you please help me here?

This error is only shown in your browser because the local linter cannot find the files. We are working on that. But it has no influence on the function. So feel free to run the script on the ctrlX CORE.

I can try to test your code in the next days.

I used your code to create my own example of reading an input and writing an output via python and writing something to the logbook of the ctrlX CORE.

If you need further support feel free to write me a direct message with your contact data so we can have a virtual meeting.

Thee also see this post for information about the print function into the logbook of the ctrlX CORE.

 

#from ctrlxpy import datalayer
import functools
print = functools.partial(print, flush=True)  # flush all prints

Channel1 = datalayer.read("fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/input/data/S20_EC_BK/S20_DI_16_4/Digital_Input_Channels.DI_Channel_01_Terminal_Point_00_")
log = str(Channel1)
print("read: ")
print(log)
Channel1 = datalayer.write("fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/output/data/S20_EC_BK/S20_DO_16_3/Digital_Output_Channels.DO_Channel_01_Terminal_Point_00_",Channel1)
print("write: ")
print(log)

 

ctrlX CORE logbook entry from pythonctrlX CORE logbook entry from python

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