lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
769 stars 449 forks source link

ModuleNotFoundError: No module named 'asyncio.exceptions' #631

Closed mwkent closed 1 year ago

mwkent commented 1 year ago

I tried setting up the homemade bot using python3.7. However, when running:

python3 lichess-bot.py -v

I received this error

Traceback (most recent call last):
  File "lichess-bot.py", line 24, in <module>
    from asyncio.exceptions import TimeoutError as MoveTimeout
ModuleNotFoundError: No module named 'asyncio.exceptions'

Switching to python3.8 resolved the error for me. It looks like asyncio.exceptions does not exist in python3.7. The documentation says Python 3.7 or later is supported: https://github.com/ShailChoksi/lichess-bot#maclinux

So I was wondering are others able to get this working with 3.7, or is 3.8 or later required?

MarkZH commented 1 year ago

I just tried this with python 3.7 and got the same error. Changing line 24 from

from asyncio.exceptions import TimeoutError as MoveTimeout

to

from asyncio import TimeoutError as MoveTimeout

fixed that error. This revealed another error on line 96:

    logging.basicConfig(level=level,
                        handlers=all_handlers,
                        force=True)

The option force was not introduced until Python 3.8.

@AttackingOrDefending Should we just change the documentation to say that Python 3.8+ is required? The second error would have started showing up six months ago in commit 86309a0d01444646dbc96b62953bbd91ee79133a, so very few users seem to be using 3.7. Plus, 3.7 is EOL on June 27.

@mwkent Do you need to use Python 3.7?

MarkZH commented 1 year ago

Also, we should probably add tests for previous python versions to our GitHub actions. Right now we only test Python 3.11.

AttackingOrDefending commented 1 year ago

I agree with dropping support for 3.7. We will also now be able to use the walrus operator (:=).

I only added the latest version because they take time and there is also a chance of failure, so by not having as many tests we avoided having to rerun the failures often. We can add tests for the earliest and latest versions only (3.8 and 3.11) to minimize failures.

mwkent commented 1 year ago

@MarkZH I do not need Python 3.7. Python 3.8 is fine for me.

MarkZH commented 1 year ago

@mwkent I'm interested to know why you are using older versions of Python. There will be times in the future when we will want to use more modern Python features to improve lichess-bot, so your reasons will help us plan for version transitions that don't inconvenience users too much.

mwkent commented 1 year ago

@MarkZH I was running my engine on an AWS EC2, and the default version of python3 on the EC2 instance was 3.7. So I was just using it for convenience.