2015-04-02 93 views
0

我正在使用wbdata包的python項目,這是一個世界銀行api的包裝器。它一直工作正常,直到我做了我所猜測的大量數據請求,我不得不取消數據請求,現在當我使用導入wbdata函數時,程序包甚至無法加載。這裏是我得到的EOF導入python包時出錯

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]: 

有人可以請幫我拿出這個包再次工作?

感謝

喬希

編輯 - 好吧運行調試%我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 

回答

1

使用IPython中的魔法%debug和檢查cachefile的文件名是什麼。如果它是一個常規文件,名字應該可以被訪問爲cachefile.name

然後覈對那個文件。

+0

%調試 > C:\用戶\約什新\安納康達\ lib中\站點包\ wbdata \ fetcher.py(84)的高速緩存() 83除了IO錯誤: ---> 84緩存= {} 85 self .__ cache = cache – Josh 2015-04-02 17:26:31

+0

呵呵,'cachefile'是一個文件對象,你需要找到文件名,因此'cachefile.name'如果是用'open()/ file()'創建的,否則你需要閱讀源代碼。 – 2015-04-02 17:27:27

+0

我假設你是指刪除核彈嗎? – Josh 2015-04-02 17:29:21

0

我想我已經通過去Appdata \ Local \ wbdata中的wbdata文件夾並刪除其中的緩存文件來修復它。現在似乎工作。