jldbc / pybaseball

Pull current and historical baseball statistics using Python (Statcast, Baseball Reference, FanGraphs)
MIT License
1.25k stars 333 forks source link

cannot import name 'pitching_stats' from partially initialized module 'pybaseball' (most likely due to a circular import) #338

Closed cruzjon2024 closed 1 year ago

cruzjon2024 commented 1 year ago
Screen Shot 2023-03-12 at 3 47 02 PM

Pleas help , I dont understand why I keep running into this issue

tjburch commented 1 year ago

Have you modified the package at all?

Python 3.10.6 (main, Aug 30 2022, 05:12:36) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pybaseball import pitching_stats
>>> pitching_stats(2012,2016)
     IDfg  Season               Name   Team  Age   W   L  WAR   ERA   G  GS  CG  ShO  SV  BS     IP  ...  Cent%+  Oppo%+  Soft%+  Med%+  Hard%+    EV    LA  Barrels  Barrel%  maxEV  HardHit  HardHit%  Events  CStr%   CSW%  xERA
4    2036    2015    Clayton Kershaw    LAD   27  16   7  8.6  2.13  33  33   4    3   0   0  232.2  ...     106      83     108    105      86  85.6   8.9       15    0.028  113.3      132     0.244     542  0.164  0.323   NaN
2    2036    2014    Clayton Kershaw    LAD   26  21   3  7.9  1.77  27  27   6    2   0   0  198.1  ...     100      82     133     98      82   NaN   NaN        0      NaN    NaN        0       NaN       0  0.161  0.303   NaN
14   2429    2014       Corey Kluber    CLE   28  18   9  7.2  2.44  34  34   3    1   0   0  235.2  ...      96     116     112     99      94   NaN   NaN        0      NaN    NaN        0       NaN       0  0.203  0.323   NaN
3    2036    2013    Clayton Kershaw    LAD   25  16   9  7.2  1.83  33  33   3    2   0   0  236.0  ...      97      84      86    106      97   NaN   NaN        0      NaN    NaN        0       NaN       0  0.178  0.293   NaN
1    4153    2015       Jake Arrieta    CHC   29  22   6  7.0  1.77  33  33   4    3   0   0  229.0  ...     106     106     123    106      75  85.1   4.4       13    0.022  111.5      143     0.247     580  0.177  0.287   NaN
..    ...     ...                ...    ...  ...  ..  ..  ...   ...  ..  ..  ..  ...  ..  ..    ...  ...     ...     ...     ...    ...     ...   ...   ...      ...      ...    ...      ...       ...     ...    ...    ...   ...
291  3273    2014  Roberto Hernandez  - - -   33   8  11  0.1  4.10  32  29   0    0   0   1  164.2  ...     108      64      90    105      98   NaN   NaN        0      NaN    NaN        0       NaN       0  0.154  0.234   NaN
201  3196    2014        Chris Young    SEA   35  12   9  0.0  3.65  30  29   0    0   0   0  165.0  ...      99      95      96     99     104   NaN   NaN        0      NaN    NaN        0       NaN       0  0.180  0.252   NaN
318  8011    2014        Eric Stults    SDP   34   8  17 -0.4  4.30  32  32   0    0   0   0  176.0  ...     101      89      86    103     105   NaN   NaN        0      NaN    NaN        0       NaN       0  0.193  0.268   NaN
396  3200    2012      Ervin Santana    LAA   29   9  13 -0.8  5.16  30  30   1    1   0   0  178.0  ...     101      87      92     96     112   NaN   NaN        0      NaN    NaN        0       NaN       0  0.176  0.260   NaN
408  7059    2016      James Shields  - - -   34   6  19 -1.0  5.85  33  33   1    0   0   0  181.2  ...      95      96      82    102     108  88.7  12.8       46    0.077  115.8      198     0.332     597  0.153  0.245   NaN

[409 rows x 334 columns]
>>> import pybaseball
>>> print(pybaseball.__version__)
2.2.5
BrayanMnz commented 1 year ago

Working also on my end.

image

any update @cruzjon2024

bdilday commented 1 year ago

I have a guess that it's because you have a file named pybaseball.py in your working directory and when you do from pybaseball import pitching_stats it's assuming you mean your local file and not the pybaseball module - can you try renaming that file to something else, pybaseball_script.py, or something?

cruzjon2024 commented 1 year ago

I have a guess that it's because you have a file named pybaseball.py in your working directory and when you do from pybaseball import pitching_stats it's assuming you mean your local file and not the pybaseball module - can you try renaming that file to something else, pybaseball_script.py, or something?

cruzjon2024 commented 1 year ago

Thank you everyone , I figured it out