我有一个简单的代码,可以通过 pyimgur 在 imgur 中创建专辑。这是代码:
@app.route('/get_album')
def get_album():
im = pyimgur.Imgur(CLIENT_ID)
new_album = im.create_album()
return new_album.link
(我也尝试im = pyimgur.Imgur(CLIENT_ID)
在路由处理程序之前使用 line,同样的事情发生了)
在 Windows 上,一切都很好。但是,当我将代码上传到我的 VPS 时,当我尝试使用 api 执行某些操作时出现以下错误: Traceback (最近一次调用最后一次):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __ca ll__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi _app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in hand le_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi _app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full _dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in hand le_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full _dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in disp atch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/api/imgur.py", line 161, in get_album_link
new_album = im.create_album()
File "/usr/local/lib/python2.7/dist-packages/pyimgur-0.4.2-py2.7.egg/pyimgur/_ _init__.py", line 754, in create_album
resp = self._send_request(url, params=payload, method='POST')
File "/usr/local/lib/python2.7/dist-packages/pyimgur-0.4.2-py2.7.egg/pyimgur/_ _init__.py", line 687, in _send_request
result = request.send_request(url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyimgur-0.4.2-py2.7.egg/pyimgur/r equest.py", line 91, in send_request
content = resp.json()
TypeError: 'dict' object is not callable
我将烧瓶更新到最新版本,并且我一直在使用 pyimgur 4,这是我从 github 获得的最新版本(pip install 不起作用,因此我不得不在 Windows 和 Ubuntu 上手动安装它,因为有关 setup.py 的一些错误会弹出出。我用python setup.py install
命令)