Mbot neo/2, Mac, Python


#1

Hi, Mbot NEO/2 and the Blocks work fine under Mac OS Monterey. When trying the following simple program in Python mode however, I get the following error regarding installing the “event” library.

According to the log, it tries to install the missing event library, which fails due to some “print” error. How can I resolve this? Are there specific steps I need to take for Mac OS Monterey to ensure compatibility?

Thanks for any help! (note that images 2 and 3 are in reverse order)

Screenshot 2022-06-22 at 11.13.25.png
Screenshot 2022-06-22 at 11.13.42.png
Screenshot 2022-06-22 at 11.14.07.png
Screenshot 2022-06-22 at 11.14.30.png


#2

The event library is only for upload mode.


#3

@PierreJo, thank you for your quick reply. I think it’s actually the opposite: for Live mode I get the required problem with event library (which I think is for Python2 since the () are missing for the print statements in the setup.py). But for Upload mode, everything seems to work as it should.

Will further try to find out what is happening, so all MacOS users can benefit. I also see that the latest release of events library has the parenthesis issue fixed (in 2015!): https://github.com/jaraco/pyevent/commit/842e0ac2609da70283309d156ce290bee9837fb3

Will report back with more details on when it works and when it fails. And thanks again for your quick response!


#4

Can you try @cyberpi.event.is_press(‘a’) instead of @event.is_press(‘a’)


#5

I tried this (commenting out the import event) and I get another error linked to the cyberpi import. I’m pretty sure now that the problem is only with the “live” mode.

Here is the error from import cyberpi:

Screenshot 2022-06-22 at 11.57.30.png
Screenshot 2022-06-22 at 11.57.10.png


#6

I try it and I have no error.

import cyberpi, time
@cyberpi.event.is_press('a')
def on_a():
      cyberpi.console.println("a")


#7

Thanks again for helping! Are you on macOS Monterey? I think it is a MacOS specific problem, I found a similar issue on the esptool.py GitHub issues, with a suggested workaround: https://github.com/espressif/esptool/issues/540


#8

I am on Windows 10.


#9

Ok thanks, that confirms it’s MacOS specific. For now if I know that the Upload mode works, I’m OK for my class, I can let my students use the block-based version in live, and the upload mode only in Python. I will keep adding here if I can narrow the problem down, so we can fix it in the long run for all Mac users. I will test now more advanced code in the upload mode and report back here.


#10

Hello, @burghout, this may be a problem with the event library not being supported yet in the python editor. You may have to learn how to code this without the include (library).

One issue may be bad code.

I would recommend that you use this code:
import event
import time
import cyberpi
Instead of this code:
import event, time, cyberpi

Your problem may also be that you need to install the cyberpi library manually by following these steps:

  1. Click the Libraries tab.

  2. Click the install button for the library cyberpi.

  3. Wait for the library to finish installing. Now it’s installed, and you can begin coding!

And lastly, the issue could also be that you don’t need the event library, it may already be included in the cyberpi library.

I hope that helps! If you could use more help, just reply and mention me as @Best_codes!

Thanks, for your time,
Best_codes


mBlock 5 vs Python editor for mBot 2
Could not install `event` library
Unable to import 'event' in python editor
#11

Hello @Best_codes, thank you very much. It is as you said, the event library has not yet been updated, and I don’t need it if I use the cyberpi.event instead after installing cyberpi as you showed above.

Thanks a lot!


#12

Thanks for responding! I just edited my post, you can look at it now!


#13

That’s great! I just remembered one more step I did to get cyberpi library to work, is to manually install using pip: pip install pyserial

Thank you again, and I hope this helps other Mac users.


#14

OK, that’s great!:grinning:


#15

Thanks @Best_codes, I totally forgot to ask him if he had dowload the cyberpi librarie.


#16

No problem! I make the same type of mistakes a lot, too! :upside_down_face:


#17

Wow, you’re on here right now! It seems like every time I’m on here, nobody else is!


#18

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