IMPORT not Working in Python


Unfortunately, I discovered a problem in the mBlock Python editor that I even think is a BUG.

I think that a major goal in STEM education is modularization as well as reusability of CODE blocks.
In my programming experience, I have regularly created collections of smaller helper functions.
This is also supported by Python via the import function. In mBlock Python, however, this unfortunately does not work (unlike in other Python IDEs - e.g. PyCharm).
I would like to demonstrate this with the following example:

Starting point is the following demonstration program:

generated by mBlock5 for CyberPi

codes make you happy

import event, time, cyberpi

def on_start():
“”“In this Program the module is called directly”""
Salutation_N_S(1, ‘Miller’)
Salutation_N_S(0, ‘’)
Salutation_N_S(2, ‘Smith’)

I want to outsource the module “Salutation_N_S” to an external file.
Therefore I have created a file in the same directory, which contains only this module.

If I then delete these lines in the main program and instead enter the line from IMPORT Salutation_N_S, it looks like this:


No error message is displayed by the editor.

If I then comment out the line from IMPORT Salutation_N_S, the calls to the function are displayed as errors:


Cross check:

I copy the source for the module additionally into the main program. Then this is recognized as a double definition.

So Python has recognized the IMPORT function correctly.

If I then start this program in live mode, an error message is displayed on the screen of the mBot.

If I switch to upload mode the following message is displayed in the editor:


Hope, You can see the problem or can say, what I can do.


Translated with (free version)


Hi phg1

Sorry for the late reply,we still can’t figure out the problem,and we have posted the problem in our group last week but up to now,we still can’t fix this problem,and thank you for your feedback we’ll send it to our algorithm engineer to fix this bug



Hi phg1

Our algorithm engineer indicates it might be a problem of capitalization and please check the file name of whether it starts with capital letters or not


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.