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)
     或

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)
相关文章
相关标签/搜索