cytoscape / py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
https://py2cytoscape.readthedocs.io
MIT License
178 stars 45 forks source link

JSONDecodeError with Python36 json decoder #31

Closed kozo2 closed 6 years ago

kozo2 commented 7 years ago
In [1]: from py2cytoscape.data.cyrest_client import CyRestClient
In [2]: cy = CyRestClient()
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-5-226b69f7d760> in <module>()
----> 1 cy = CyRestClient()

/Users/kozo2/miniconda3/lib/python3.6/site-packages/py2cytoscape/data/cyrest_client.py in __init__(self, ip, port, version)
     17 
     18         self.network = NetworkClient(self.__url)
---> 19         self.style = StyleClient(self.__url)
     20         self.layout = LayoutClient(self.__url)
     21         self.edgebundling = EdgeBundlingClient(self.__url)

/Users/kozo2/miniconda3/lib/python3.6/site-packages/py2cytoscape/data/style_client.py in __init__(self, url)
     14         self.__url_apply = url + 'apply/styles/'
     15 
---> 16         self.vps = VisualProperties(url)
     17 
     18     def create(self, name=None, original_style=None):

/Users/kozo2/miniconda3/lib/python3.6/site-packages/py2cytoscape/data/style_client.py in __init__(self, url)
     71     def __init__(self, url):
     72         self.__url = url + 'styles/visualproperties'
---> 73         self.__convert_to_dict()
     74 
     75     def __convert_to_dict(self):

/Users/kozo2/miniconda3/lib/python3.6/site-packages/py2cytoscape/data/style_client.py in __convert_to_dict(self)
     74 
     75     def __convert_to_dict(self):
---> 76         vps = requests.get(self.__url).json()
     77         vp_dict = {}
     78         node_vps = []

/Users/kozo2/miniconda3/lib/python3.6/site-packages/requests/models.py in json(self, **kwargs)
    848                     # used.
    849                     pass
--> 850         return complexjson.loads(self.text, **kwargs)
    851 
    852     @property

/Users/kozo2/miniconda3/lib/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    352             parse_int is None and parse_float is None and
    353             parse_constant is None and object_pairs_hook is None and not kw):
--> 354         return _default_decoder.decode(s)
    355     if cls is None:
    356         cls = JSONDecoder

/Users/kozo2/miniconda3/lib/python3.6/json/decoder.py in decode(self, s, _w)
    337 
    338         """
--> 339         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    340         end = _w(s, end).end()
    341         if end != len(s):

/Users/kozo2/miniconda3/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
    355             obj, end = self.scan_once(s, idx)
    356         except StopIteration as err:
--> 357             raise JSONDecodeError("Expecting value", s, err.value) from None
    358         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

You can reproduce this error with

kozo2 commented 7 years ago

This error does not occur in Python27.

iwatobipen commented 6 years ago

Dear, I got same error message when I run the example code. I would like to use py2cytoscape with python3.x. Any comments or advices are appreciated. My environment is below. Ubuntu16.04 anaconda / python3.5 cytoscape 3.5.1 py2cytoscape 0.62 Kind regards,

iwatobipen commented 6 years ago

Dear, My problem was due to system proxy settings. I wrote my proxy settings in bashrc. Py2cytoscape requests.get(self.url) uses system proxy settings. But localhost does not need proxy.

At first I cleared my settings and run the code, it worked. Thank you.