尝试运行COM浏览器时出错

时间:2016-10-30 22:25:35

标签: python pywin32

我安装了Python 3.5.2(4def2a2901a5)64位和pywin32 v.220。

当我尝试从PyWin窗口运行COM浏览器时,出现以下错误:

Failed to execute command:
from win32com.client import combrowse;combrowse.main()
Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 60, in __init__
    _LoadDicts()
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 110, in _LoadDicts
    f = open(os.path.join(win32com.__gen_path__, "dicts.dat"), "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\Python35\\lib\\site-packages\\win32com\\gen_py\\dicts.dat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 143, in GetGeneratePath
    os.stat(fname)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Program Files\\Python35\\lib\\site-packages\\win32com\\gen_py\\__init__.py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python35\Lib\site-packages\pythonwin\pywin\framework\toolmenu.py", line 103, in HandleToolCommand
    exec("%s\n" % pyCmd)
  File "<string>", line 1, in <module>
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\__init__.py", line 11, in <module>
    from . import gencache
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 666, in <module>
    __init__()
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 62, in __init__
    Rebuild()
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 653, in Rebuild
    _SaveDicts()
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 69, in _SaveDicts
    f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
  File "C:\Program Files\Python35\lib\site-packages\win32com\client\gencache.py", line 145, in GetGeneratePath
    f = open(fname,"w")
PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\Python35\\lib\\site-packages\\win32com\\gen_py\\__init__.py'

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您想获取有关您使用的com-ports的信息吗? 你的问题并不清楚......

如果&#34;是&#34;,您也可以简单地

    import serial.tools.list_ports

    def scan_comports(self):        
        correct_port = 'none'
        ports = list(serial.tools.list_ports.comports())
        for p in ports:
              print "%s %s"%(p[0], p[1])
              if str(p[1]).startswith("SomeComportName"):
                 correct_port = p[0]

因为我不知道并且从不需要&#34; win32com.client&#34; 用于python中的comport操作我无法帮助这个模块(这对我来说无关紧要,因为comports是串行端口。 。)