Openshift上的Simplejson错误

时间:2014-05-23 15:38:55

标签: python openshift simplejson

我一直在本地使用外部Python包rapportive.py,效果很好。现在我正在尝试在OpenShift上使用它。我能够通过requirements.txt&成功安装软件包。我可以导入它,但每当我尝试使用它时,我都会得到一个JSONDecodeError:

Python 2.7.5 (default, Aug 16 2013, 05:57:04) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> from rapportive import rapportive
>>> profile = rapportive.request("test@test.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/openshift/537830065973ca131b00036b/app-root/runtime/dependencies/python/virtenv/src/rapportive/rapportive/rapportive.py", line 83, in request
    response = requests.get(status_url).json()
  File "/var/lib/openshift/537830065973ca131b00036b/python/virtenv/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/models.py", line 763, in json
    return json.loads(self.text, **kwargs)
  File "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/simplejson/__init__.py", line 453, in loads
    return _default_decoder.decode(s)
  File "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 429, in decode
    obj, end = self.raw_decode(s)
  File "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 451, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

我不确定这是否是一个OpenShift问题,或者我是否遗漏了一些非常简单的问题。但无论哪种方式,我都可以提供帮助。谢谢!

1 个答案:

答案 0 :(得分:0)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/openshift/537830065973ca131b00036b/app-root/runtime/dependencies/python/virtenv/src/rapportive/rapportive/rapportive.py", line 83, in request
    response = requests.get(status_url).json()

堆栈跟踪的这一部分表示rapportive.py中失败的行,然后表明requests.get()未返回可在JSON对象中转换的有效响应。这是您使用相同的测试用户在本地测试的完全相同的代码吗?

尝试在OpenShift上运行以下代码,看看是否有任何错误:

import requests
STATUS_URL = 'https://rapportive.com/login_status?user_email=test@test.com'
response = requests.get(STATUS_URL)

如果该代码没有错误,那么应该可以运行response.json而不会出错。这应该至少指出你正确的方向是什么问题。