Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

获取二维码时出现 FileNotFoundError: [Errno 2] No such file or directory: 'xdg-open' #5

Closed
n1majne3 opened this issue Mar 6, 2017 · 2 comments
Labels

Comments

@n1majne3
Copy link

n1majne3 commented Mar 6, 2017

大大您好,我今天在自己的服务器上尝试配置wxpy,做到第二步获取二维码时报错,
机器是ubuntu14.04 root用户登陆
屏幕输出如下

>>> robot = Robot()
Getting uuid of QR code.
Downloading QR code.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/wxpy/wx.py", line 1024, in __init__
    loginCallback=login_callback, exitCallback=logout_callback
  File "/usr/local/lib/python3.4/dist-packages/itchat/components/register.py", line 35, in auto_login
    loginCallback=loginCallback, exitCallback=exitCallback)
  File "/usr/local/lib/python3.4/dist-packages/itchat/components/login.py", line 39, in login
    picDir=picDir, qrCallback=qrCallback)
  File "/usr/local/lib/python3.4/dist-packages/itchat/components/login.py", line 96, in get_QR
    utils.print_qr(picDir)
  File "/usr/local/lib/python3.4/dist-packages/itchat/utils.py", line 82, in print_qr
    subprocess.call(['xdg-open', fileDir])
  File "/usr/lib/python3.4/subprocess.py", line 537, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'xdg-open'

请问是我遗漏了什么步骤吗

@youfou
Copy link
Owner

youfou commented Mar 6, 2017

在服务器上运行,可以使用终端二维码,请注意下面文档中 console_qr 参数说明
http://wxpy.readthedocs.io/zh/latest/api/robot.html?highlight=console_qr#wxpy.Robot

试试

robot = Robot(console_qr=True)

@guzhongzheng
Copy link

如果捕获这个异常,跳过继续执行,二维码可以保存成图片。否则程序异常就终止执行了。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants