使用Pandas和多处理模块时的属性错误

时间:2015-01-27 19:21:57

标签: python pandas multiprocessing

我是Python的新手,正在构建一个在后台进程中查询数据库的应用程序,然后将结果粘贴到pandas数据集中进行某些分析。我可以让分析和查询部分独立工作;但是,当我结合我的代码时,我得到以下错误(一直重复,直到我杀死程序):

'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'
'module' object has no attribute 'day_abbr'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\multiprocessing\forking.py", line 495, in prepare
    '__parents_main__', file, path_name, etc
  File "G:\Stress Test\PPNR Models\Model_Management_App\Model_Mgnt_Proj\ModelMgntMainDeleteThis.py", line 5, in <module>
    import pandas as pd
  File "C:\Users\z083423\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\__init__.py", line 6, in <module>
    from . import hashtable, tslib, lib
  File "tslib.pyx", line 3744, in init pandas.tslib (pandas\tslib.c:66221)
  File "tslib.pyx", line 3662, in pandas.tslib.TimeRE.__init__ (pandas\tslib.c:53412)
  File "tslib.pyx", line 3545, in pandas.tslib.LocaleTime.__init__ (pandas\tslib.c:51221)
  File "tslib.pyx", line 3565, in pandas.tslib.LocaleTime.__calc_weekday (pandas\tslib.c:51571)
AttributeError: 'module' object has no attribute 'day_abbr'

我读过的所有内容都可能是命名空间错误,我导入的模块具有共享相同名称的属性。我把它缩小到我对大熊猫和多处理模块的导入(即如果我用一个,但不是另一个它可以正常工作)。在线有很多例子可以成功导入这两个模块。我可以运行这些例子;然而,当我尝试做一些自定义的事情时,我无法让它发挥作用。我确定我错过了什么。下面是一些给我错误的代码示例。任何帮助将非常感谢!

import wx
import time

import sys

import pandas as pd
import multiprocessing as mp

def Worker():
    time.sleep(3)
    return [(1,2),(2,3),(4,5)]

class TheApp(wx.App):
     def OnInit(self):
         mainFrame = MainFrame(None, 'Test')
         mainFrame.Show()
         return True

class MainFrame(wx.Frame):

    def __init__(self, theParent, theTitle):
        wx.Frame.__init__(self, parent=theParent, title=theTitle, size=(200,200))
        self.Centre()
        myPanel = wx.Panel(self)
        self.myLabel = wx.StaticText(myPanel, -1, label="Start")

        pool = mp.Pool(4)
        pool.apply_async(func=Worker, callback=self.CallBackFunc)       

        #self.CallBackFunc([(1,2),(2,3),(4,5)])

    def CallBackFunc(self, returnValue):
        reader = pd.DataFrame.from_records(returnValue)
        self.myLabel.SetLabel(str(reader.get_value(1,1,True)))
        self.Refresh()           

if __name__ == "__main__":
    app = TheApp(False)
    app.MainLoop()
    sys.exit(0)

0 个答案:

没有答案