pybaseball icon indicating copy to clipboard operation
pybaseball copied to clipboard

schedule_and_record(2005, "HOU") fails with "Data cannot be retrieved for this team/year combo" even though page exists

Open tuta23 opened this issue 1 month ago • 4 comments

Summary

Calling schedule_and_record for the 2005 Houston Astros fails with:

ValueError: Data cannot be retrieved for this team/year combo. Please verify that your team abbreviation is accurate and that the team existed during the season you are searching for.

The Baseball-Reference page for this team/year does exist and contains a schedule table.

example

from pybaseball import schedule_and_record

df = schedule_and_record(2005, "HOU")

http://www.baseball-reference.com/teams/HOU/2005-schedule-scores.shtml
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
File ...\site-packages\pybaseball\team_results.py:28, in get_table(soup, team)
    27 try:
--> 28     table = soup.find_all('table')[0]
    29 except:
IndexError: list index out of range


During handling of the above exception, another exception occurred:

ValueError: Data cannot be retrieved for this team/year combo. Please verify that your team abbreviation is accurate and that the team existed during the season you are searching for.

This happens for me in Jupyter Notebook in an Anaconda environment. Tried for several combinations of teams, years.

The URL printed by pybaseball does load correctly in a browser and appears to contain the schedule table:

https://www.baseball-reference.com/teams/HOU/2005-schedule-scores.shtml

Thank you!

pybaseball version: 2.2.7 pandas version: 2.3.3 Python version: 3.13.9

tuta23 avatar Nov 28 '25 15:11 tuta23

Hey - can you follow the instructions on https://github.com/jldbc/pybaseball/issues/487#issuecomment-3369080798 and follow up if you're still having issues?

MancusoM avatar Dec 01 '25 01:12 MancusoM

I was unable to utilize Git to re-install/upgrade, but I manually modified the bref.py to match the version in master.

Unfortunately, no change -- it still fails.

tuta23 avatar Dec 02 '25 22:12 tuta23

Can you put the error in a gist and send it here? I was just able to run the function without issue

MancusoM avatar Dec 04 '25 01:12 MancusoM

When I started pulling this together, I realized that curl_cffi which is now called in the updated "bref.py" file was not installed in my environment.

I went ahead and installed that package, and it now appears to be working. I'll keep an eye on things I as continue to use pybaseball, but I think this can be closed.

Thank you!

tuta23 avatar Dec 04 '25 17:12 tuta23

Can confirm that following this fix solves the issue of not being able to use schedule_and_record!

andrewscheiner avatar Dec 16 '25 17:12 andrewscheiner