<span>itchat 报错 OSError: [WinError -2147221003] 找不到应用程序: 'QR.png'</span>

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)
全部评论

相关推荐

06-20 21:22
已编辑
门头沟学院 Java
纯真的河老师在喝茶:答应了就跑啊,实习随便跑啊,别被pua了,md就是找个廉价劳动力,还平稳过度正式工,到时候跟你说没转正
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务