2

我只是在 Mac 上修改 xlwings 以将值写入单元格。但是,当我初始化一个新工作簿时,我得到了这个:

import xlwings as xl
wb = xl.Workbook()


Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/Developer/anaconda/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/Developer/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 30, in clean_up
    app('Microsoft Excel').run_VB_macro('CleanUp')
  File "/Developer/anaconda/lib/python2.7/site-packages/aeosa/appscript/reference.py", line 579, in __getattr__
    raise AttributeError("Unknown property, element or command: %r" % name)
AttributeError: Unknown property, element or command: 'run_VB_macro'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/Developer/anaconda/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/Developer/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 30, in clean_up
    app('Microsoft Excel').run_VB_macro('CleanUp')
  File "/Developer/anaconda/lib/python2.7/site-packages/aeosa/appscript/reference.py", line 579, in __getattr__
    raise AttributeError("Unknown property, element or command: %r" % name)
AttributeError: Unknown property, element or command: 'run_VB_macro' 

Excel 确实打开并创建了一个新文件,但随后发生了异常。我不明白为什么它会在 Mac 上运行时尝试运行宏。我知道作者在这里。希望他能参与进来。

4

2 回答 2

0

我在 OS X Yosemite 10.10.2、Office 2011 v14.4.6、Python 3.4.2 和 xlwings 0.3.0 上没有收到此错误。

也许您为 Python 2.7 安装了 xlwings?以 su 的身份尝试以下命令:pip3 install xlwings

于 2015-01-03T16:04:45.037 回答
0

我唯一一次遇到类似这样的错误,问题出在我安装 Anaconda 的位置。我使用安装程序提供的默认位置卸载并重新安装它,之后一切正常。

这是安装/卸载 Anaconda 的指南:http: //docs.continuum.io/anaconda/install

于 2015-08-17T11:51:09.503 回答