itchat 報錯 OSError: [WinError -2147221003] 找不到應用程序: 'QR.png'


OSError: [WinError -2147221003] 找不到應用程序: ‘QR.png’
原因:   
缺少在windows下相關處理方法

解決方法:
找到你運行環境

D:\python\Lib\site-packages\itchat

打開utils
修改此函數

def print_qr(fileDir):
    if config.OS == 'Darwin':
        subprocess.call(['open', fileDir])
    elif config.OS == 'Linux':
        subprocess.call(['xdg-open', fileDir])
    else:
        os.startfile(fileDir)

修改后

import webbrowser
def print_qr(fileDir):
    if config.OS == 'Darwin':
        subprocess.call(['open', fileDir])
    elif config.OS == 'Linux':
        subprocess.call(['xdg-open', fileDir])
    elif config.OS =='Windows':
        webbrowser.open(fileDir)

    chrome_path = r'C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe'
    webbrowser.register('chrome',None,webbrowser.BackgroundBrowser(chrome_path))
    webbrowser.get('chrome').open_new_tab(fileDir)
else:
    os.startfile(fileDir)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM