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

OSError: [WinError -2147221003] 找不到应用程序: 'QR.png'   
原因:
  缺少在windows 下相关处理方法
  

解决方法:
找到你运行环境
C:\Python36\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)
     或
        file_path = os.path.join(os.getcwd(),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(file_path)
    else:
os.startfile(fileDir)


猜你喜欢

转载自www.cnblogs.com/yanxiatingyu/p/10374367.html