ly0 / baidupcsapi

百度网盘api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

登录时报 No such file or directory: 'gvfs-open' 错误

leetschau opened this issue · comments

commented
>>> from baidupcsapi import PCS
>>> pcs = PCS('myusername', 'mypassword')
/tmp/tmpxptvms49.png
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-890c11b1394a> in <module>()
----> 1 pcs = PCS('leetschau', 'nodeJS@2017')

~/.local/share/virtualenvs/baidupcs-8fRt-h26/lib/python3.5/site-packages/baidupcsapi/api.py in __init__(self, username, password, captcha_callback, verify_callback)
    499         """
    500         super(PCS, self).__init__(username, password, captcha_func=captcha_callback,
--> 501                                   verify_func=verify_callback)
    502
    503     def __err_handler(self, act, errno, callback=None, args=(), kwargs=None):

~/.local/share/virtualenvs/baidupcs-8fRt-h26/lib/python3.5/site-packages/baidupcsapi/api.py in __init__(self, username, password, captcha_func, verify_func)
    167         logging.debug('setting pcs server')
    168         self.set_pcs_server(self.get_fastest_pcs_server())
--> 169         self._initiate()
    170
    171     @staticmethod

~/.local/share/virtualenvs/baidupcs-8fRt-h26/lib/python3.5/site-packages/baidupcsapi/api.py in _initiate(self)
    226             self.session.get('http://www.baidu.com')
    227             self.user['token'] = self._get_token()
--> 228             self._login()
    229
    230     def _save_cookies(self):

~/.local/share/virtualenvs/baidupcs-8fRt-h26/lib/python3.5/site-packages/baidupcsapi/api.py in _login(self)
    318                 self.codeString = code_string
    319                 logging.debug('need captcha, codeString=' + code_string.decode('utf-8'))
--> 320                 captcha = self._get_captcha(code_string)
    321                 continue
    322

~/.local/share/virtualenvs/baidupcs-8fRt-h26/lib/python3.5/site-packages/baidupcsapi/api.py in _get_captcha(self, code_string)
    263         if code_string:
    264             verify_code = self.captcha_func(
--> 265                     "https://passport.baidu.com/cgi-bin/genimage?" + code_string.decode('utf-8'))
    266         else:
    267             verify_code = ""

~/.local/share/virtualenvs/baidupcs-8fRt-h26/lib/python3.5/site-packages/baidupcsapi/api.py in default_captcha_handler(image_url)
     58         subprocess.call([filename], shell=True)
     59     elif os_name == 'Linux':
---> 60         subprocess.call(['gvfs-open', filename])
     61     elif os_name == 'Darwin':
     62         subprocess.call(['open', filename])

/usr/lib/python3.5/subprocess.py in call(timeout, *popenargs, **kwargs)
    555     retcode = call(["ls", "-l"])
    556     """
--> 557     with Popen(*popenargs, **kwargs) as p:
    558         try:
    559             return p.wait(timeout=timeout)

/usr/lib/python3.5/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start
_new_session, pass_fds)
    945                                 c2pread, c2pwrite,
    946                                 errread, errwrite,
--> 947                                 restore_signals, start_new_session)
    948         except:
    949             # Cleanup if the child failed starting.

/usr/lib/python3.5/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, r
estore_signals, start_new_session)
   1549                             else:
   1550                                 err_msg += ': ' + repr(orig_executable)
-> 1551                     raise child_exception_type(errno_num, err_msg)
   1552                 raise child_exception_type(err_msg)
   1553

FileNotFoundError: [Errno 2] No such file or directory: 'gvfs-open'

操作系统:Ubuntu 16.04.

$ pip freeze
baidupcsapi==0.9.3
certifi==2018.1.18
chardet==3.0.4
decorator==4.2.1
idna==2.6
ipython==6.2.1
ipython-genutils==0.2.0
jedi==0.11.1
parso==0.1.1
pexpect==4.4.0
pickleshare==0.7.4
prompt-toolkit==1.0.15
ptyprocess==0.5.2
pyasn1==0.4.2
Pygments==2.2.0
requests==2.18.4
requests-toolbelt==0.8.0
rsa==3.4.2
simplegeneric==0.8.1
six==1.11.0
traitlets==4.3.2
urllib3==1.22
wcwidth==0.1.7

安装需求里没有gvfs方面的要求,它是做什么用的呢?谢谢!

emmmm 应该是某次某人提交的时候一个默认行为

目标是打开一个图片浏览器打开验证码,可以具体换成你local打开的命令
或者给定一个captcha_handler处理

commented

能否解释一下这部分代码的逻辑,我可以尝试fix一下。

行为是 打开一个系统相关的图片浏览器打开验证码