Openshift上的Simplejson错误



我一直在本地使用外部Python包rapportivepy,它工作得很好。现在我正试图在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的问题,还是我错过了一些非常简单的东西。但不管怎样,我都能帮上忙。谢谢!

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而没有错误。这至少可以为您指明问题所在的正确方向。

最新更新