0

我正在开发一个项目,该项目利用 python 的 wbdata 包,它是世界银行 api 的包装器。它工作得很好,直到我提出了我猜想的大量数据请求,我不得不取消它,现在当我使用 import wbdata 函数时,甚至不会加载包。这就是我得到的

Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC 

v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.

In [1]: import wbdata as wb

Traceback (most recent call last):

  File "<ipython-input-1-ae1872a5f07c>", line 1, in <module>
    import wbdata as wb

  File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\__init__.py", line 23, in <module>
    from .api import (get_country, get_data, get_dataframe, get_panel,

  File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\api.py", line 31, in <module>
    from . import fetcher

  File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\fetcher.py", line 104, in <module>
    if not len(CACHE.cache)== 0:

  File "C:\Users\Josh New\Anaconda\lib\site-packages\wbdata\fetcher.py", line 82, in cache
    cache = pickle.load(cachefile)

EOFError


In [2]: 

有人可以帮我让这个包再次工作吗?

谢谢

乔什

编辑-运行 %debug cachefile.name 后,我得到以下信息;

   %debug cachefile.name
NOTE: Enter 'c' at the ipdb>  prompt to continue execution.
> c:\users\josh new\anaconda\lib\encodings\cp1252.py(15)decode()
     14     def decode(self,input,errors='strict'):
---> 15         return codecs.charmap_decode(input,errors,decoding_table)
     16 


ipdb> c
Traceback (most recent call last):
  File "C:\Users\Josh New\Anaconda\lib\site-packages\IPython\core\magics\execution.py", line 817, in _run_with_debugger
    deb.run(code, code_ns)
  File "C:\Users\Josh New\Anaconda\lib\bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
NameError: name 'cachefile' is not defined
4

2 回答 2

1

使用 ipython 的魔法%debug并检查cachefile文件名是什么。如果它是一个常规文件,则 name 应该可以作为cachefile.name.

然后核对那个文件。

于 2015-04-02T17:24:00.627 回答
0

我想我已经通过进入 Appdata\Local\wbdata 中的 wbdata 文件夹并删除其中的缓存文件来修复它。似乎现在可以工作了。

于 2015-04-02T17:59:24.157 回答