'Why is my Discord Bot in GitHub not working?

When I run main.py it's giving me this error. I was just trying to replicate a bot from GitHub and I didn't know it would be this difficult, here is the GitHub:

https://github.com/Normynator/RagnaDBot

C:\testebot\RagnaDBot>python main.py
INFO:Config logging is enabled and set to: 10
DEBUG:Using proactor: IocpProactor
Traceback (most recent call last):
  File "C:\testebot\RagnaDBot\main.py", line 29, in <module>
    _settings = load.load_settings(_config)
  File "C:\testebot\RagnaDBot\lib\load.py", line 11, in load_settings
    document = yaml.load(document)
TypeError: load() missing 1 required positional argument: 'Loader'```

load.py:

#!/usr/bin/env python3
import yaml
import logging
from lib import mvp  # required for yaml
from lib.mvp import MVP


def load_settings(path):
    with open(path) as f:
        document = f.read()
        document = yaml.load(document)   - i think the problem is possibly here
        logging.debug(document)
    return document

main.py:

# Path to the config file
_config = "config.yml"
_client = discord.Client()
_settings = load.load_settings(_config) -    problem possibly be here too
_mvp_list = load.parse_mvp_list(_settings['mvp_list'])
_channel = discord.Object(id=_settings['channel_id'])
_debug_core = False
_time_mult = 60  # .sleep works with seconds, to get minutes multiply by 60


Solution 1:[1]

You are using PyYAML's old load() function which for the longest time defaulted to possible unsafe behavior on unchecked YAML. That is why in 2020 this default was finally deprecated.

If you don't have any tags in your YAML you should use:

document = yaml.safe_load(document)

if you do have tags in your YAML you can use

`yaml.load(document, Loader=yaml.FullLoader)`

, but note that would require registering of classes for the tags. Few (too few) programs use tags, so try the safe_load option first to see if that works.

Please note that the recommended extension for YAML files has been .yaml since 2006.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anthon