Cyberpi has no attribute 'get_shield'


I’m having problem importing cyberpi, in the python editor.

this simple code:

import cyberpi
print('hello world')

results in this error message:

Traceback (most recent call last):
    File "C:\Users\pnaze\.mcode\virtualFS\projects\default\/hellomakeblock/", line 1, in <module>
        import cyberpi
    File "C:\Users\pnaze\.mcode\site-packages\cyberpi\", line 11, in <module>
AttributeError: module 'makeblock.modules.cyberpi.api_cyberpi_api' has no attribute 'get_shield'

I’m running mBlock v5.4.0
in the python editor
with python 3.6.5

>>> sys.version
'3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46)

on Windows 10.

Can you please help me resolve this error.



found the problem and its solution.

On Feb 8th of 2022, version 0.0.7 of cyberpi was released. This version has a bug that results in the ‘get_shield’ error above. Meaning anyone who recently received mbot recently and attempted to install cyberpi after Feb 8th 2022 has had this problem, but those who installed cyberpi before Feb 8th don’t have this problem.

The solution is to go back to version 0.0.5.

Go to Python Editor.
Write this three line script and “Run” it.

import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "cyberpi==0.0.5"])

now you can import the cyberpi package.