如何弄清楚这个Python异常

时间:2017-10-13 14:22:30

标签: python

我完全迷失了这个,并且完全不知道如何解决这个问题。

背景

我已经使用TK前端编写了一个小应用程序。它确实读取了三个csv报告并将它们合并为一个。所有这些都在我的机器上处理。我的一位同事现在已经使用这个应用程序一段时间了,直到四周前也没有任何问题。每当处理第三个报告时,都会显示以下反馈:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 1945, in get_loc
    return self._engine.get_loc(key)
  File "pandas\index.pyx", line 137, in pandas.index.IndexEngine.get_loc (pandas\index.c:4154)
  File "pandas\index.pyx", line 159, in pandas.index.IndexEngine.get_loc (pandas\index.c:4018)
  File "pandas\hashtable.pyx", line 675, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12368)
  File "pandas\hashtable.pyx", line 683, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12322)
KeyError: 'EXTENSION'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\tkinter\__init__.py", line 1550, in __call__
    return self.func(*args)
  File "C:\Users\username\BillingEngine_2\Python files\GUI.py", line 148, in <lambda>
    command=lambda: run_merge_engineering_reports())
  File "C:\Users\username\BillingEngine_2\Python files\GUI.py", line 28, in run_merge_engineering_reports
    er_Switzerland = read_files.read_special_countries_er(base_dir, ",", "Switzerland")
  File "C:\Users\username\BillingEngine_2\Python files\read_files.py", line 47, in read_special_countries_er
    print("There are", engineering_data["EXTENSION"].count(), "extensions from the Engineering Report in\n", fullpath)
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 1997, in __getitem__
    return self._getitem_column(key)
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2004, in _getitem_column
    return self._get_item_cache(key)
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\generic.py", line 1350, in _get_item_cache
    values = self._data.get(item)
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py", line 3290, in get
    loc = self.items.get_loc(item)
  File "C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 1947, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas\index.pyx", line 137, in pandas.index.IndexEngine.get_loc (pandas\index.c:4154)
  File "pandas\index.pyx", line 159, in pandas.index.IndexEngine.get_loc (pandas\index.c:4018)
  File "pandas\hashtable.pyx", line 675, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12368)
  File "pandas\hashtable.pyx", line 683, in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12322)
KeyError: 'EXTENSION'

这远远超出了我对编程的了解,因此我寻求帮助或至少提出初步建议。

到目前为止我们检查了什么

当然,我们正在尝试显而易见的事情:

  • 我们是否有完全相同的报告?
  • 我们是否有相同的Python文件(相同版本)?
  • 我们使用相同的Python(最新的Anaconda环境)吗?

我们可以回答&#34;是&#34;每一个人(通过webex检查,因为我的同事坐在国外)。我们唯一无法确保的是机器完全相同。但这一切都有效,直到四周前,我们所知道的一切都没有任何根本性的变化。

我的理解

似乎表明无法找到专栏&#39; EXTENSION&#39; (KeyError异常)。但它肯定存在,并且在我的机器上它处理它没有任何问题。

感谢您的想法。

0 个答案:

没有答案