在Mac机器上pip install pywin32失败

问题描述

如何在Mac机器上下载pip install pywin32。我要求使用以下代码将pdf转换为docs文件

import glob
import win32com.client
import os

word = win32com.client.dispatch("Word.Application")
word.visible = 0

pdfs_path = "C:\\Users\\bthakur4\\Downloads\\pdf\\"
for i,doc in enumerate(glob.iglob(pdfs_path +"inputfiles\\" +"*[A-Za-z0-9 _].pdf")):
    #print(doc)
    filename = doc.split('\\')[-1]
    in_file = os.path.abspath(doc)
    print("\n")
    print("converting file: ",in_file)
    wb = word.Documents.Open(in_file)
    out_file = os.path.abspath(pdfs_path + "outputfiles\\" +filename[0:-4]+ ".docx".format(i))
    wb.SaveAs2(out_file,FileFormat=16)
    print("success...")
    print("output file: ",out_file)
    wb.Close()

word.Quit()

。或其他任何方式?

解决方法

你根本做不到。 pywin32是用于Windows API调用的 Windows Python包装器