報錯:OSError: [WinError -2147221003] 找不到應(yīng)用程序: ‘QR.png’
原因:缺少在windows下相關(guān)處理方法
解決步驟:
1、找到你運(yùn)行環(huán)境? X:*\python\Lib\site-packages\itchat? (?注 : X:*\ 代表你的Python庫所在路徑)
2、打開utils? ?修改此py文件內(nèi)的如下內(nèi)容:
修改前
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':
? ? ? ? #默認(rèn)在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)