Could not install `event` library


#1

In the Python editor containing a simple program:

# generated by mBlock5 for CyberPi
# codes make you happy

import mbot2, time, event, cyberpi

@event.is_press('a')
def is_btn_press():
    mbot2.straight(100)
    cyberpi.led.show('red orange yellow green cyan')

When I click “Run”, it opens a prompt:

event library not found, so the project may not run as expected.

Install event library right now?

I click “Yes”, but installation fails, with the following logs:

Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting mbot2
Downloading https://mirrors.aliyun.com/pypi/packages/ed/53/cd94b03365e859427c370acf47be576e61ccf6cc04eb88ca44149ca69ab7/mbot2-0.0.2-py3-none-any.whl (12 kB)
Requirement already satisfied, skipping upgrade: pyserial in c:\public\programs\mblock\resources\app\mlink-v2\exec\python-env\win\lib\site-packages (from mbot2) (3.4)
Installing collected packages: mbot2
Successfully installed mbot2-0.0.2
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting event
Downloading https://mirrors.aliyun.com/pypi/packages/d7/e9/3f88290f7a6add3e150b04d61cd989d07b0e5394c37f8bbc32d5a2ee263f/event-0.4.3.zip (56 kB)
|██████ | 10 kB 43 kB/s eta 0:00:02
|███████████▌ | 20 kB 45 kB/s eta 0:00:01
|█████████████████▌ | 30 kB 45 kB/s eta 0:00:01
|███████████████████████ | 40 kB 45 kB/s eta 0:00:01
|█████████████████████████████ | 51 kB 45 kB/s eta 0:00:01
|████████████████████████████████| 56 kB 44 kB/s
ERROR: Command errored out with exit status 1: command: 'C:\Public\Programs\mblock\resources\app\mlink-v2\exec\python-env\win\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\\\AppData\\Local\\Temp\\pip-install-210pvolu\\event\\setup.py'"'"'; __file__='"'"'C:\\\\AppData\\Local\\Temp\\pip-install-210pvolu\\event\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' e gg_info --egg-base 'C:\AppData\Local\Temp\pip-install-210pvolu\event\pip-egg-info' cwd: C:\AppData\Local\Temp\pip-install-210pvolu\event\ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\AppData\Local\Temp\pip-install-210pvolu\event\setup.py", line 20 print 'found libevent build directory', best ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('found libevent build directory', best)? ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting event
Downloading https://mirrors.aliyun.com/pypi/packages/d7/e9/3f88290f7a6add3e150b04d61cd989d07b0e5394c37f8bbc32d5a2ee263f/event-0.4.3.zip (56 kB)
|██████ | 10 kB 43 kB/s eta 0:00:02
|███████████▌ | 20 kB 45 kB/s eta 0:00:01
|█████████████████▌ | 30 kB 45 kB/s eta 0:00:01
|███████████████████████ | 40 kB 44 kB/s eta 0:00:01
|█████████████████████████████ | 51 kB 44 kB/s eta 0:00:01
|████████████████████████████████| 56 kB 45 kB/s
ERROR: Command errored out with exit status 1: command: 'C:\Public\Programs\mblock\resources\app\mlink-v2\exec\python-env\win\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\\\AppData\\Local\\Temp\\pip-install-j0bqq10i\\event\\setup.py'"'"'; __file__='"'"'C:\\\\AppData\\Local\\Temp\\pip-install-j0bqq10i\\event\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' e gg_info --egg-base 'C:\AppData\Local\Temp\pip-install-j0bqq10i\event\pip-egg-info' cwd: C:\AppData\Local\Temp\pip-install-j0bqq10i\event\ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\AppData\Local\Temp\pip-install-j0bqq10i\event\setup.py", line 20 print 'found libevent build directory', best ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('found libevent build directory', best)? ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting event
Downloading https://mirrors.aliyun.com/pypi/packages/d7/e9/3f88290f7a6add3e150b04d61cd989d07b0e5394c37f8bbc32d5a2ee263f/event-0.4.3.zip (56 kB)
|██████ | 10 kB 46 kB/s eta 0:00:01
|███████████▌ | 20 kB 45 kB/s eta 0:00:01
|█████████████████▌ | 30 kB 45 kB/s eta 0:00:01
|███████████████████████ | 40 kB 45 kB/s eta 0:00:01
|█████████████████████████████ | 51 kB 46 kB/s eta 0:00:01
|████████████████████████████████| 56 kB 46 kB/s
ERROR: Command errored out with exit status 1: command: 'C:\Public\Programs\mblock\resources\app\mlink-v2\exec\python-env\win\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\\\AppData\\Local\\Temp\\pip-install-me9l7d_w\\event\\setup.py'"'"'; __file__='"'"'C:\\\\AppData\\Local\\Temp\\pip-install-me9l7d_w\\event\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' e gg_info --egg-base 'C:\AppData\Local\Temp\pip-install-me9l7d_w\event\pip-egg-info' cwd: C:\AppData\Local\Temp\pip-install-me9l7d_w\event\ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\AppData\Local\Temp\pip-install-me9l7d_w\event\setup.py", line 20 print 'found libevent build directory', best ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print('found libevent build directory', best)? ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

mBlock 5 vs Python editor for mBot 2
#2

Check this old post out:


#3

I checked, but this does not help.

Btw, I have the same error message if I try to install event in the PIP tab from that “Libraries” menu.

There is definitely a syntax error in some setup.py file, but I’m a bit lost on Windows: the path seems to be C:\AppData\Local\Temp\pip-install-j0bqq10i\event\setup.py, but C:\AppData does not even exist.

This error prevents me to run a python program when I press CyberPi button (because it requires @event.is_press('a')).


#4

Oh, with the old mBlock python editor (the “Python” tab on the right), it works!

It’s not intuitive, because it opens an empty text file: Suggestion: Hint for viewing/editing micropython code in UI
But you can get the python code generated from the blocks, copy-paste it there, (edit it) then “upload”, and it works.

This is the only way I managed to run some python code I edited manually on the robot.


#5

I’m glad you have a workaround until a solution can be found!