chembl / chembl_webresource_client

Official Python client for accessing ChEMBL API
https://www.ebi.ac.uk/chembl/api/data/docs
Other
377 stars 95 forks source link

simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #14

Closed medozz closed 8 years ago

medozz commented 8 years ago

Hi,

I find the above error message after I successfully installed the ChEMBL web-resource client package. My code was only this: from chembl_webresource_client import * The whole message is as follows: Traceback (most recent call last): File "C:/Working_projects/Cancer_related_fristeighbours/Experimental_validation/Python_project/Search_for_chemble_data_for_compounds.py", line 9, in <module> from chembl_webresource_client import * File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\__init__.py", line 23, in <module> from chembl_webresource_client.utils import utils File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\utils.py", line 8, in <module> utils = client_from_url(Settings.Instance().utils_spore_url) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\spore_client.py", line 17, in client_from_url schema = session.get(url).json() File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\requests\models.py", line 826, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\__init__.py", line 516, in loads return _default_decoder.decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0) I have reinstalled simple json package for Anaconda. I think it can be some kind of file coding issue either within simplejson or in ChEMBL. I am not sure what is the file coding for the requested files from the url.

I am using Anaconda on a windows machine. See below all of my package versions. alabaster==0.7.7 anaconda-client==1.2.2 argcomplete==1.0.0 astropy==1.1.1 Babel==2.2.0 backports-abc==0.4 backports.ssl-match-hostname==3.4.0.2 beautifulsoup4==4.4.1 bitarray==0.8.1 blaze==0.9.0 bokeh==0.11.0 boto==2.39.0 Bottleneck==1.0.0 cdecimal==2.3 cffi==1.2.1 chembl-webresource-client==0.6.3 clyent==1.2.0 colorama==0.3.6 comtypes==1.1.2 conda==4.1.11 conda-build==1.19.0 conda-env==2.5.0a0 configobj==5.0.6 cryptography==0.9.1 cycler==0.9.0 Cython==0.23.4 cytoolz==0.7.5 datashape==0.5.0 decorator==4.0.6 docutils==0.12 easydict==1.5 enum34==1.1.2 et-xmlfile==1.0.1 fastcache==1.0.2 Flask==0.10.1 funcsigs==0.4 futures==3.0.3 gevent==1.0.2 gevent-websocket==0.9.5 greenlet==0.4.9 grequests==0.2.0 grin==1.2.1 h5py==2.5.0 idna==2.0 ipaddress==1.0.14 ipykernel==4.2.2 ipython==4.1.1 ipython-genutils==0.1.0 ipywidgets==4.1.1 itsdangerous==0.24 jdcal==1.2 jedi==0.9.0 Jinja2==2.8 jsonschema==2.4.0 jupyter==1.0.0 jupyter-client==4.1.1 jupyter-console==4.1.0 jupyter-core==4.0.6 llvmlite==0.8.0 lxml==3.5.0 MarkupSafe==0.23 matplotlib==1.5.1 menuinst==1.4.1 mistune==0.7.1 multipledispatch==0.4.8 nbconvert==4.1.0 nbformat==4.0.1 networkx==1.11 nltk==3.1 nose==1.3.7 notebook==4.1.0 numba==0.23.1 numexpr==2.4.6 numpy==1.11.1 odo==0.4.0 openpyxl==2.3.2 pandas==0.17.1 path.py==0.0.0 patsy==0.4.0 pep8==1.7.0 pickleshare==0.5 Pillow==3.1.0 ply==3.8 psutil==3.4.2 py==1.4.31 pyasn1==0.1.9 pycairo==1.10.0 pycosat==0.6.1 pycparser==2.14 pycrypto==2.6.1 pyflakes==1.0.0 Pygments==2.1.1 pyOpenSSL==0.15.1 pyparsing==2.0.3 pyreadline==2.1 pytest==2.8.5 python-dateutil==2.4.2 python-igraph==0.7.1.post6 pytz==2015.7 pywin32==219 PyYAML==3.11 pyzmq==15.2.0 qtconsole==4.1.1 requests==2.11.1 requests-cache==0.4.4 rope==0.9.4 ruamel-yaml===-VERSION scikit-image==0.11.3 scikit-learn==0.17.1 scipy==0.18.0 simplegeneric==0.8.1 simplejson==3.8.2 singledispatch==3.4.0.3 six==1.10.0 snowballstemmer==1.2.1 sockjs-tornado==1.0.1 sphinx==1.3.5 sphinx-rtd-theme==0.1.9 spyder==2.3.8 SQLAlchemy==1.0.11 statsmodels==0.6.1 sympy==0.7.6.1 tables==3.2.2 toolz==0.7.4 tornado==4.3 traitlets==4.1.0 unicodecsv==0.14.1 uniprot-tools==0.4.1 urllib3==1.16 Werkzeug==0.11.3 xlrd==0.9.4 XlsxWriter==0.8.4 xlwings==0.6.4 xlwt==1.0.0 Thanks for any help,

Dezso

mnowotka commented 8 years ago

Hi Dezso,

Thanks for reporting this. It would be good to get some additional information before we proceed. Can you try to execute the import statement once again but this time add this BEFORE import:

import logging
logging.basicConfig()
logging.basicConfig(level=logging.DEBUG)

And paste the output here. Let's see what's going on...

medozz commented 8 years ago

Hi,

I got the same error message I hope you get the log. Code: import logging logging.basicConfig() logging.basicConfig(level=logging.DEBUG) from chembl_webresource_client import * Result: Traceback (most recent call last): File "C:/Working_projects/Cancer_related_fristeighbours/Experimental_validation/Python_project/Search_for_chemble_data_for_compounds.py", line 10, in <module> from chembl_webresource_client import * File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\__init__.py", line 23, in <module> from chembl_webresource_client.utils import utils File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\utils.py", line 8, in <module> utils = client_from_url(Settings.Instance().utils_spore_url) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\spore_client.py", line 17, in client_from_url schema = session.get(url).json() File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\requests\models.py", line 826, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\__init__.py", line 516, in loads return _default_decoder.decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

mnowotka commented 8 years ago

OK, then, can you do:

from chembl_webresource_client.settings import Settings
url = Settings.Instance().UTILS_SPORE_URL
print url

import requests
r = requests.get(url)
print r.status_code
print r.ok
print r.json()

And paste results?

medozz commented 8 years ago

Hi,

It gives the same results. Code: from chembl_webresource_client.settings import Settings url = Settings.Instance().UTILS_SPORE_URL print url import requests r = requests.get(url) print r.status_code print r.ok print r.json()

Result: Traceback (most recent call last): File "C:/Working_projects/Cancer_related_fristeighbours/Experimental_validation/Python_project/Search_for_chemble_data_for_compounds.py", line 6, in <module> from chembl_webresource_client.settings import Settings File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\__init__.py", line 23, in <module> from chembl_webresource_client.utils import utils File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\utils.py", line 8, in <module> utils = client_from_url(Settings.Instance().utils_spore_url) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\spore_client.py", line 18, in client_from_url schema = session.get(url).json() File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\requests\models.py", line 826, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\__init__.py", line 516, in loads return _default_decoder.decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

mnowotka commented 8 years ago
  1. First of all there are some print statements in my code and I asked you to paste them so we can have a look.
  2. Secondly as you see you are getting an error although you are not using the client (strictly speaking you are using just one constant with the endpoint URL I asked you to print).

So either the URL is wrong (which I doubt) or you have some problems with internet connection. But I can say for sure because you did not include output of print statements.

medozz commented 8 years ago

Hi,

I can reach Chembl with a simple: import urllib f = urllib.urlopen("https://www.ebi.ac.uk/chembl/") data = f.read() print data > 0 from chembl_webresource_client.settings import Settings Results: True But after that I get the same error message. I think it is because the data are feed by start to json. Could it be the encoding of any of the files? It can be my python as well, because mine is: 2.7.12 |Anaconda 2.5.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] Sorry for the inconvenience. Thanks for the help,

Dezso

mnowotka commented 8 years ago

@medozz - I gave you a piece of code with print statements and asked you to execute it and give me the output. Can you please do it for me? Otherwise I won't be able to help you.

medozz commented 8 years ago

The code does not run, because the import statement is before the print statements. You sent: from chembl_webresource_client.settings import Settings url = Settings.Instance().UTILS_SPORE_URL print url

import requests r = requests.get(url) print r.status_code print r.ok print r.json()

The first line does not run, and the code can not go further. That is the problem. :( It seems the ChEMBL library cannot imported. Traceback (most recent call last): File "C:/Working_projects/Cancer_related_fristeighbours/Experimental_validation/Python_project/Search_for_chemble_data_for_compounds.py", line 17, in <module> from chembl_webresource_client.settings import Settings File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\__init__.py", line 23, in <module> from chembl_webresource_client.utils import utils File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\gevent\builtins.py", line 93, in __import__result = _import(*args, **kwargs) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\utils.py", line 8, in <module> utils = client_from_url(Settings.Instance().utils_spore_url) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\chembl_webresource_client\spore_client.py", line 18, in client_from_url schema = session.get(url).json() File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\requests\models.py", line 826, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\__init__.py", line 516, in loads return _default_decoder.decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "C:\Users\dm729\AppData\Local\Continuum\Anaconda2\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Sorry for not inserting it again, but it has the same error.

mnowotka commented 8 years ago

OK, what if you try:

import requests
url = 'https://www.ebi.ac.uk/chembl/api/utils/spore'
r = requests.get(url)
print r.status_code
print r.ok
print r.json()
medozz commented 8 years ago

I found it myself as well, so: https://wwwdev.ebi.ac.uk/chembl/api/utils/spore 500 False Then error message.

mnowotka commented 8 years ago

If your UTILS_SPORE_URL points to https://wwwDEV.ebi.ac.uk/chembl/api/utils/spore instead of https://wwwdev.ebi.ac.uk/chembl/api/utils/spore this means you installed the unstable version of the client directly from this repo instead of using official stable version from PIP:

pip install -U chembl_webresource_client
medozz commented 8 years ago

THANK YOU VERY MUCH!

It works. Sorry for any inconvenience.