导入python包时出错EOF

时间:2015-04-02 17:19:09

标签: python python-2.7 importerror eoferror

我正在开发一个利用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

2 个答案:

答案 0 :(得分:1)

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

然后核对那个文件。

答案 1 :(得分:0)

我想我已经通过在Appdata \ Local \ wbdata中输入wbdata文件夹并删除其中的缓存文件来修复它。似乎现在有效。