joenano / rpscrape

Scrape horse racing results data and racecards.
140 stars 57 forks source link

Unable to run rpscrape.py (AttributeError: 'str' object has no attribute 'decode') #100

Closed berningf closed 2 years ago

berningf commented 2 years ago

Steps to reproduce on a Mac Air M1:

  1. Create a new python 3.8.12 environment using Anaconda Navigator UI
  2. Activate env in Terminal
  3. Run pip install -r requirements.txt
  4. Run git clone https://github.com/joenano/rpscrape.git
  5. CD into scripts folder and run python3 rpscrape.py
(rpscrape) fb@MacBook-Air scripts % ./rpscrape.py 
Traceback (most recent call last):
  File "./rpscrape.py", line 20, in <module>
    settings = Settings()
  File "/Users/fb/Documents/GitHub/rpscrape/scripts/utils/settings.py", line 7, in __init__
    self.toml = self.load_toml()
  File "/Users/fb/Documents/GitHub/rpscrape/scripts/utils/settings.py", line 37, in load_toml
    toml = self.parse_toml(settings_file)
  File "/Users/fb/Documents/GitHub/rpscrape/scripts/utils/settings.py", line 48, in parse_toml
    return tomli.load(settings_file)
  File "/Users/fb/opt/anaconda3/envs/rpscrape/lib/python3.8/site-packages/tomli/_parser.py", line 55, in load
    s = __fp.read().decode()
AttributeError: 'str' object has no attribute 'decode'
joenano commented 2 years ago

I dont have mac or anaconda. Try installing the latest version of tomli with pip instead.

therealweewlad commented 2 years ago

the issue is with the version of tomli, version 2.0.0 was released last month. If you use version 1.2.3, it works fine.

https://pypi.org/project/tomli/#history

berningf commented 2 years ago

Confirmed tomli version 1.2.2 resolves issue.

phillc73 commented 2 years ago

Just a short confirmation that I had the same issue on a Debian 11 system with Python 3.9 installed.

Downgrading tomli to v1.2.3 fixed the issue.

Thanks for the resolution posted here!