OSError: [WinError -2147221003] 找不到应用程序: 'QR.png'

报错:OSError: [WinError -2147221003] 找不到应用程序: ‘QR.png’

原因:缺少在windows下相关处理方法   

解决步骤:

1、找到你运行环境  X:*\python\Lib\site-packages\itchat  ( 注 : X:*\ 代表你的Python库所在路径)

2、打开utils   修改此py文件内的如下内容:

修改前

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':

        #默认在ie浏览器打开二维码

        webbrowser.open(fileDir)

        #如果ie浏览器不能打开可以使用一下代码

        file_path = os.path.join(os.getcwd(),fileDir)

        chrome_path = r'C:\Users\PC\AppData\Local\Google\Chrome\Application\chrome.exe'

        webbrowser.register('chrome',None,webbrowser.BackgroundBrowser(chrome_path))

        webbrowser.get('chrome').open_new_tab(file_path)

    else:

        os.startfile(fileDir)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容