xlwings runpython安装失败

2024-05-12 12:55:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在mac上使用xlwings(10.11.5)和Excel 2016 for mac(版本15.23.2),但我很快就被卡住了。在

当我跑的时候 xlwings runpython安装 我得到以下错误:

$ xlwings runpython install
Traceback (most recent call last):
  File "/usr/local/bin/xlwings", line 7, in <module>
    from xlwings.command_line import main
  File "/Library/Python/2.7/site-packages/xlwings/command_line.py", line 22, in <module>
    hfs_to_posix_path(app('Microsoft Excel').properties().get(k.templates_path))))
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 577, in __getattr__
    selectortype, code = self.AS_appdata.referencebyname()[name]
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 259, in referencebyname
    self.connect()
  File "/Library/Python/2.7/site-packages/aeosa/appscript/reference.py", line 225, in connect
    t = self._target = self._aemapplicationclass(**kargs)
  File "/Library/Python/2.7/site-packages/aeosa/aem/__init__.py", line 76, in __init__
    self._address = aemconnect.localapp(path, newinstance, hide)
  File "/Library/Python/2.7/site-packages/aeosa/aem/aemconnect.py", line 187, in localapp
    desc = _launchapplication(path, _runevent, newinstance, hide)
  File "/Library/Python/2.7/site-packages/aeosa/aem/aemconnect.py", line 55, in _launchapplication
    raise CantLaunchApplicationError(err.args[0], path)
aem.aemconnect.CantLaunchApplicationError: Can't launch application at u'/Applications/Microsoft Excel.app': The executable file is missing or has an unusable format. (-10827)

有什么办法吗?在

版本: Python 2.7.10 xlwings(0.7.2) psutil(4.3.0) appscript(1.0.1)


Tags: pathinpyselfpackageslinelibrarysite
2条回答

我发现了问题: 基本上,我是在与Excel不同的用户环境中运行xlwings runpython install。在

现在还不太清楚为什么它失败了,但是xlwings runpython install尝试做的只是将xlwings.appscript文件从xlwings安装目录复制到以下目录:~/Library/Application Scripts/com.microsoft.Excel。因此,要解决这个问题,您只需手动将文件复制到该目录中(如果该目录不存在,请创建该目录)。您可以通过执行以下操作来找到xlwings的安装路径:

>>> import xlwings as xw
>>> xw.__path__

相关问题 更多 >