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