OliverSherouse / wbdata

A python library for accessing world bank data
GNU General Public License v2.0
180 stars 55 forks source link

Unpickling error? #62

Closed anshver92 closed 6 months ago

anshver92 commented 3 years ago

After installing using pip install wbdata I am getting a pickling error on doing just a simple import wbdata as wb command:

UnpicklingError                           Traceback (most recent call last)
<ipython-input-21-08dfa68d526a> in <module>
----> 1 import wbdata as wb

~\Anaconda3\envs\WorldBank\lib\site-packages\wbdata\__init__.py in <module>
      4 __version__ = "0.3.0"
      5 
----> 6 from .api import (  # noqa: F401
      7     get_country,
      8     get_data,

~\Anaconda3\envs\WorldBank\lib\site-packages\wbdata\api.py in <module>
     16 
     17 from decorator import decorator
---> 18 from . import fetcher
     19 
     20 BASE_URL = "https://api.worldbank.org/v2"

~\Anaconda3\envs\WorldBank\lib\site-packages\wbdata\fetcher.py in <module>
     62 
     63 
---> 64 CACHE = Cache()
     65 
     66 

~\Anaconda3\envs\WorldBank\lib\site-packages\wbdata\fetcher.py in __init__(self)
     40                 self.cache = {
     41                     i: (date, json)
---> 42                     for i, (date, json) in pickle.load(cachefile).items()
     43                     if (TODAY - datetime.date.fromordinal(date)).days < EXP
     44                 }

UnpicklingError: pickle data was truncated

When I had previously installed this package I remember I did have to restart the kernel for something because it was being too slow. Could something have become corrupted like this? I tried creating a new environment and reinstalling but this didn't work either. Thanks for any help!

anshver92 commented 3 years ago

Maybe perhaps there is a way of clearing that cache? My guess is that would sort it out?

OliverSherouse commented 3 years ago

Yes, that will solve that for now, I'll also open an issue to do it automatically on a failed load. What operating system are you using?

anshver92 commented 3 years ago

Yep so confirmed I located where the cache was being stored. Deleted the folder, uninstalled the package and reinstalled it and it seems to work. My OS is Windows 10.

ValeCKalpha commented 3 years ago

It seems that i have the same problem.

File "c:/Users/Administrator/Desktop/wbdatadownload.py", line 1, in import wbdata File "D:\vnstudio\lib\site-packages\wbdata__init.py", line 6, in from .api import ( # noqa: F401 File "D:\vnstudio\lib\site-packages\wbdata\api.py", line 18, in from . import fetcher File "D:\vnstudio\lib\site-packages\wbdata\fetcher.py", line 64, in CACHE = Cache() File "D:\vnstudio\lib\site-packages\wbdata\fetcher.py", line 42, in init__ for i, (date, json) in pickle.load(cachefile).items() _pickle.UnpicklingError: pickle data was truncated

ValeCKalpha commented 3 years ago

So where can i find the cache being stored? My OS is Windows 7. Many thanks!

OliverSherouse commented 3 years ago

@ValeCKalpha Should be at" C:\Documents and Settings\\Application Data\Local Settings\wbdata\wbdata", where is your username.

ValeCKalpha commented 3 years ago

Thanks !

ValeCKalpha commented 3 years ago

@ValeCKalpha Should be at" C:\Documents and Settings\Application Data\Local Settings\wbdata\wbdata", where is your username.

My Windows runs well now. But my MacOS has the same question just now. I would like to ask where to find the cache in MacOS? Thanks~

OliverSherouse commented 3 years ago

@ValeCKalpha "~/Library/Application Support/wbdata"

ValeCKalpha commented 3 years ago

@ValeCKalpha "~/Library/Application Support/wbdata"

thks