littlecodersh / ItChat

A complete and graceful API for Wechat. 微信个人号接口、微信机器人及命令行微信,三十行即可自定义个人号机器人。
http://itchat.readthedocs.io
MIT License
25.42k stars 5.63k forks source link

OSError: [Errno 2] No such file or directory #154

Closed john916zhang closed 7 years ago

john916zhang commented 7 years ago

➜ ~ python wx.py Getting uuid of QR code. Downloading QR code.

Traceback (most recent call last):
  File "wx.py", line 24, in <module>
    itchat.auto_login(True)
  File "/usr/local/lib/python2.7/dist-packages/itchat/components/register.py", line 23, in auto_login
    loginCallback=loginCallback, exitCallback=exitCallback)
  File "/usr/local/lib/python2.7/dist-packages/itchat/components/login.py", line 37, in login
    if self.get_QR(enableCmdQR=enableCmdQR, picDir=picDir):
  File "/usr/local/lib/python2.7/dist-packages/itchat/components/login.py", line 88, in get_QR
    utils.print_qr(picDir)
  File "/usr/local/lib/python2.7/dist-packages/itchat/utils.py", line 71, in print_qr
    subprocess.call(['xdg-open', fileDir])
  File "/usr/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
littlecodersh commented 7 years ago

@anderson916 当前目录下有生成二维码吗? python有权限在本目录写入二维码吗?

john916zhang commented 7 years ago

生成了二维码。

screen shot 2016-11-16 at 8 53 03 pm
littlecodersh commented 7 years ago

@anderson916 你是使用的什么程序运行该项目? 如果使用命令行是否可以打开该文件?

xdg-open QR.jpg
john916zhang commented 7 years ago
➜  ~ ./wx.py
Getting uuid of QR code.
Downloading QR code.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/run-mailcap line 528.
Error: no "view" mailcap rules found for type "image/jpeg"
/usr/bin/xdg-open: 771: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 771: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 771: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 771: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 771: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 771: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'QR.jpg'
Please scan the QR code to log in.
littlecodersh commented 7 years ago

@anderson916 你试试这个选项 先装上pillow

pip install pillow

然后改成一下auto_login命令

itchat.auto_login(enableCmdQR=True)
john916zhang commented 7 years ago

可以了。谢谢。

19940308cai commented 6 years ago

image 请问这种情况,是我少了什么东西没装吗?@littlecodersh

erictioh commented 5 years ago

I think you have to install xdg-utils before the it can try to open it. The command line is another way.

for centos: yum install xdg-utils