wbdata icon indicating copy to clipboard operation
wbdata copied to clipboard

Unpickling error?

Open anshver92 opened this issue 4 years ago • 10 comments

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 avatar Aug 27 '20 12:08 anshver92

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

anshver92 avatar Aug 27 '20 13:08 anshver92

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?

OliverSherouse avatar Aug 27 '20 14:08 OliverSherouse

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.

anshver92 avatar Aug 27 '20 14:08 anshver92

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 avatar Oct 26 '20 02:10 ValeCKalpha

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

ValeCKalpha avatar Oct 27 '20 02:10 ValeCKalpha

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

OliverSherouse avatar Oct 27 '20 13:10 OliverSherouse

Thanks !

ValeCKalpha avatar Oct 27 '20 13:10 ValeCKalpha

@ValeCKalpha Should be at" C:\Documents and Settings<User>\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~

ValeCKalpha avatar Oct 27 '20 13:10 ValeCKalpha

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

OliverSherouse avatar Oct 27 '20 13:10 OliverSherouse

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

thks

ValeCKalpha avatar Oct 27 '20 13:10 ValeCKalpha