通过python打开Excel文档时出现问题

2024-09-30 16:21:48 发布

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

我不是一个非常高级的python用户,我正在处理的一个程序有问题。我可以让它在一台计算机上正常工作,但现在当我尝试在另一台计算机上运行时,它就不工作了。在

我基本上是把它写进excel文件里然后再把它保存起来。在

这是错误

   Traceback (most recent call last):
  File "C:\Users\aainstall\Desktop\Python\DD\DDcreatemacrosheets10_27_14.py", line 70, in <module>
    wb = excel.Workbooks.Open("Allmacro.xlsx")
  File "C:\Python34\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x7\Workbooks.py", line 78, in Open
    , Converter, AddToMru, Local, CorruptLoad)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "'Allmacro.xlsx' could not be found. Check the spelling of the file name, and verify that the file location is correct.\n\nIf you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.", 'xlmain11.chm', 0, -2146827284), None)

这是相关代码。在

^{pr2}$

我对问题可能是什么以及即将解决它感到困惑。它要查找的文件就在那里,并且在正确的位置。所以我不知道是什么问题。在

我尝试运行此程序的两台计算机都使用Windows 7。它工作的计算机使用的是python3.3,而不工作的计算机使用的是python3.4。两台计算机都安装了excel2010。在


Tags: 文件theinpy程序most计算机line