lichess-bot-devs / lichess-bot

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

Lichess bot does not work #667

Closed SeN4PA1 closed 1 year ago

SeN4PA1 commented 1 year ago

My lichess bot doesnt work and in cmd prompt it says this:

[02/14/23 10:48:53] INFO lichess-bot.py:783 . /| . // o\ . || .) lichess-bot 2023.2.11.1 . //__\ . )___( Play on Lichess with a bot

                ERROR    Quitting lichess-bot due to an error:                                    lichess-bot.py:843
                         Traceback (most recent call last):
                           File "xxxxxxxxxxxxxxBot\lichess-bot-master\lichess-bot.py",
                         line 840, in <module>
                             start_lichess_bot()
                           File "xxxxxxxxxxxxxxxxlichess-bot-master\lichess-bot.py",
                         line 784, in start_lichess_bot
                             CONFIG = load_config(args.config or "./config.yml")
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                           File "xxxxxxxxxxxxxxxxxBot\lichess-bot-master\config.py", line
                         197, in load_config
                             config_assert(os.path.isdir(CONFIG["engine"][""]),
                                                         ~~~~~~~~~~~~~~~~^^^^
                         KeyError: ''

I have placed the 'x's as they have private info.

Why is this happening? The code where it says the problem is is here:

logging_level = logging.DEBUG if args.v else logging.INFO logging_configurer(logging_level, args.logfile) logger.info(intro(), extra={"highlighter": None}) CONFIG = load_config(args.config or "./config.yml") (LINE 784) max_retries = CONFIG.engine.online_moves.max_retries check_python_version() li = lichess.Lichess(CONFIG.token, CONFIG.url, version, logging_level, max_retries)

and here:

if name == "main": multiprocessing.set_start_method('spawn') try: while restart: restart = False start_lichess_bot() (LINE 840) time.sleep(10 if restart else 0) except Exception: logger.exception("Quitting lichess-bot due to an error:")

Can you help?

MarkZH commented 1 year ago

It looks like line 197 of config.py got changed somehow. Check your copy of config.py and see if that line is different from this:

        config_assert(os.path.isdir(CONFIG["engine"]["dir"]),
                      f'Your engine directory `{CONFIG["engine"]["dir"]}` is not a directory.')
SeN4PA1 commented 1 year ago

After I copy that code into line 197 of my config.py, it still shows error with the following:

Quitting lichess-bot due to an error: lichess-bot.py:843 Traceback (most recent call last): File "xxxxxxxxxxBot\lichess-bot-master\lichess-bot.py", line 840, in start_lichess_bot() File xxxxxxxxxxxxBot\lichess-bot-master\lichess-bot.py", line 784, in start_lichess_bot CONFIG = load_config(args.config or "./config.yml") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "xxxxxxxxxlichess-bot-master\config.py", line 197, in load_config config_assert(os.path.isdir(CONFIG["engine"]["dir"]), File xxxxxxxxxxxBot\lichess-bot-master\config.py", line 46, in config_assert raise Exception(error_message) Exception: Your engine directory ./engines/SeNP4A1_bot is not a directory.

MarkZH commented 1 year ago

Run

python lichess-bot.py -v -l log.txt

and paste the whole content of log.txt here.

SeN4PA1 commented 1 year ago

Here:

[02/14/23 12:01:07] INFO                                                                              lichess-bot.py:783
                                 .   _/|
                                 .  // o\
                                 .  || ._)  lichess-bot 2023.2.11.1
                                 .  //__\
                                 .  )___(   Play on Lichess with a bot

                    DEBUG    Config:                                                                       config.py:171
                             token: logger
                             url: https://lichess.org/
                             engine:
                               dir: ./engines/SeNP4A1_bot
                               name: SeN4PA1_bot
                               working_dir: ''
                               protocol: uci
                               ponder: true
                               polyglot:
                                 enabled: false
                                 book:
                                   standard:
                                   - engines/book1.bin
                                   - engines/book2.bin
                                 min_weight: 1
                                 selection: weighted_random
                                 max_depth: 8
                               draw_or_resign:
                                 resign_enabled: false
                                 resign_score: -1000
                                 resign_for_egtb_minus_two: true
                                 resign_moves: 3
                                 offer_draw_enabled: false
                                 offer_draw_score: 0
                                 offer_draw_for_egtb_zero: true
                                 offer_draw_moves: 5
                                 offer_draw_pieces: 10
                               online_moves:
                                 max_out_of_book_moves: 10
                                 max_retries: 2
                                 chessdb_book:
                                   enabled: false
                                   min_time: 20
                                   move_quality: good
                                   min_depth: 20
                                   contribute: true
                                 lichess_cloud_analysis:
                                   enabled: false
                                   min_time: 20
                                   move_quality: good
                                   max_score_difference: 50
                                   min_depth: 20
                                   min_knodes: 0
                                 online_egtb:
                                   enabled: false
                                   min_time: 20
                                   max_pieces: 7
                                   source: lichess
                                   move_quality: best
                               lichess_bot_tbs:
                                 syzygy:
                                   enabled: false
                                   paths:
                                   - engines/syzygy
                                   max_pieces: 7
                                   move_quality: best
                                 gaviota:
                                   enabled: false
                                   paths:
                                   - engines/gaviota
                                   max_pieces: 5
                                   min_dtm_to_consider_as_wdl_1: 120
                                   move_quality: best
                               homemade_options: null
                               uci_options:
                                 Move Overhead: 100
                                 Threads: 2
                                 Hash: 256
                                 SyzygyPath: ./syzygy/
                               silence_stderr: false
                             abort_time: 20
                             fake_think_time: false
                             rate_limiting_delay: 0
                             move_overhead: 2000
                             correspondence:
                               move_time: 60
                               checkin_period: 600
                               disconnect_time: 300
                               ponder: false
                             challenge:
                               concurrency: 1
                               sort_by: best
                               accept_bot: false
                               only_bot: false
                               max_increment: 180
                               min_increment: 0
                               max_base: 315360000
                               min_base: 0
                               max_days: 14
                               min_days: 1
                               variants:
                               - standard
                               time_controls:
                               - bullet
                               - blitz
                               - rapid
                               modes:
                               - casual
                               - rated
                             greeting:
                               hello: Hi! I'm {me}. Good luck! Type !help for a list of commands I can
                             respond
                                 to.
                               goodbye: Good game!
                               hello_spectators: Hi! I'm {me}. Type !help for a list of commands I can
                             respond
                                 to.
                               goodbye_spectators: Thanks for watching!
                             matchmaking:
                               allow_matchmaking: false
                               challenge_variant: random
                               challenge_timeout: 30
                               challenge_initial_time:
                               - 60
                               - 120
                               challenge_increment:
                               - 1
                               - 2
                               opponent_rating_difference: 100
                               opponent_allow_tos_violation: true
                               challenge_mode: random
                               delay_after_decline: none

                    DEBUG    ====================                                                          config.py:172
                    ERROR    Quitting lichess-bot due to an error:                                    lichess-bot.py:843
                             Traceback (most recent call last):
                               File "xxxxxxxxxxxx\lichess-bot-master\lichess-bot.py",
                             line 840, in <module>
                                 start_lichess_bot()
                               File "xxxxxxxxxxxxlichess-bot-master\lichess-bot.py",
                             line 784, in start_lichess_bot
                                 CONFIG = load_config(args.config or "./config.yml")
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                               File " ot\lichess-bot-master\config.py", line
                             197, in load_config
                                 config_assert(os.path.isdir(CONFIG["engine"]["dir"]),
                               File "xxxxxxxxxxxxBot\lichess-bot-master\config.py", line
                             46, in config_assert
                                 raise Exception(error_message)
                             Exception: Your engine directory `./engines/SeNP4A1_bot` is not a
                             directory.
MarkZH commented 1 year ago

In your config.yml file, try changing

                             engine:
                               dir: ./engines/SeNP4A1_bot
                               name: SeN4PA1_bot

to

                             engine:
                               dir: ./engines/
                               name: SeN4PA1_bot

The dir entry should only be a directory that contains the engine executable file. The name of the executable file should be in name.

SeN4PA1 commented 1 year ago

Now it says:

Quitting lichess-bot due to an error: lichess-bot.py:843 Traceback (most recent call last): File "xDocuments\Boxxxxxxxxxxxxt\lichess-bot-master\lichess-bot.py", line 840, in start_lichess_bot() File "xxxxxxxxxxxBot\lichess-bot-master\lichess-bot.py", line 795, in start_lichess_bot is_bot = upgrade_account(li) ^^^^^^^^^^^^^^^^^^^ File "xxxxxxxxxxxxxBot\lichess-bot-master\lichess-bot.py", line 70, in upgrade_account if li.upgrade_to_bot_account() is None: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "xxxxxxxxxxxxxxxBot\lichess-bot-master\lichess.py", line 155, in upgrade_to_bot_account return self.api_post("upgrade") ^^^^^^^^^^^^^^^^^^^^^^^^ File "xxxxxxxxxxxxxxxxxxBot\lichess-bot-master.venv\Lib\site-packages \backoff_sync.py", line 105, in retry ret = target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "xxxxxxxxxxxxxxxxx\Bot\lichess-bot-master\lichess.py", line 132, in api_post response.raise_for_status() File "xxxxxxxxxxxxx\Bot\lichess-bot-master.venv\Lib\site-packages \requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://lichess.org/api/bot/account/upgrade

MarkZH commented 1 year ago

Has the account you're trying to upgrade played any games? Did you create a bot:play token for the account?

MarkZH commented 1 year ago

If you are still having problems with getting your bot set up, please reopen this issue and provide more details.