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

KeyError: '.json' When Running `molecule.get('CHEMBL25')` #24

Closed Superraptor closed 7 years ago

Superraptor commented 7 years ago

First, great work here, I love the extensiveness of this API, its breadth is incredible.

I was just having a minor issue (which might just be me overlooking the obvious), but when I run one of the example queries:

from chembl_webresource_client.new_client import new_client
molecule = new_client.molecule
m1 = molecule.get('CHEMBL25')

I get the following stack on the line m1 = molecule.get('CHEMBL25'):

  File "C:\Users\User Name\Anaconda3\lib\site-packages\chembl_webresource_client\query_set.py", line 177, in get
    return self.query.get(*args, **kwargs)
  File "C:\Users\User Name\Anaconda3\lib\site-packages\chembl_webresource_client\url_query.py", line 267, in get
    return self._get_by_ids(args[0])
  File "C:\Users\User Name\Anaconda3\lib\site-packages\chembl_webresource_client\url_query.py", line 292, in _get_by_ids
    headers = {'Accept': mimetypes.types_map['.'+self.frmt]}
KeyError: '.json'

I'm not really sure what to try and would appreciate any pointers in the right direction! Thanks!

mnowotka commented 7 years ago

Hi,

Thanks for reporting this. Can you please give me the following information:

I tried with the latest version (0.9.13) of the client with Python 2.7.6 and 2.7.13 on OSX and Ununtu and I can't reproduce your problem.

Superraptor commented 7 years ago

Sure!

I'm running Python 3.4.5 :: Anaconda custom (64-bit) [via python --version]

OS is Windows 10 Home (System type is 64-bit, x64-based processor)

conda list output:

# packages in environment at C:\Users\User Name\Anaconda3:
#
_license                  1.1                      py34_1
alabaster                 0.7.9                    py34_0
anaconda                  custom                   py34_0
anaconda-client           1.5.3                    py34_0
argcomplete               1.0.0                    py34_1
astropy                   1.2.1               np111py34_0
attrs                     15.2.0                   py34_0
babel                     2.3.4                    py34_0
backports_abc             0.4                      py34_0
bagofwords                1.0.3                     <pip>
bcolz                     1.0.0                    py34_0
beautiful-soup            4.3.2                    py34_1
biased-stop-words         2017.7.13.0               <pip>
binstar                   0.12                          2
biopython                 1.70                      <pip>
bitarray                  0.8.1                    py34_1
blaze-core                0.9.0                    py34_0
blz                       removed                       0
bokeh                     0.12.3                   py34_1
boto                      2.43.0                   py34_0
bottleneck                1.1.0               np111py34_0
bzip2                     1.0.6                    vc10_3  [vc10]
c3d                       0.3.0                     <pip>
certifi                   2016.2.28                py34_0
cffi                      1.8.3                    py34_0
chardet                   2.3.0                     <pip>
chembl-webresource-client 0.9.13                    <pip>
ChemSpiPy                 1.0.4                     <pip>
click                     6.6                      py34_0
clyent                    1.2.2                    py34_0
colorama                  0.3.7                    py34_0
comtypes                  1.1.2                    py34_0
conda                     4.3.25                   py34_0
conda-build               2.0.7                    py34_0
conda-env                 2.6.0                         0
configobj                 5.0.6                    py34_0
constantly                15.1.0                   py34_0
cryptography              1.5.2                    py34_0
cssselect                 1.0.0                    py34_0
cycler                    0.10.0                   py34_0
cython                    0.25.1                   py34_0
cytoolz                   0.8.0                    py34_0
datashape                 0.5.2                    py34_0
decorator                 4.0.10                   py34_0
Django                    1.10.2                    <pip>
docutils                  0.12                     py34_2
dynd-python               removed                       0
easydict                  1.7                       <pip>
entrypoints               0.2.2                    py34_0
et_xmlfile                1.0.1                    py34_0
eutils                    0.3.1                     <pip>
fastcache                 1.0.2                    py34_1
filelock                  2.0.6                    py34_0
flask                     0.11.1                   py34_0
freetype                  2.5.5                    vc10_1  [vc10]
future                    0.16.0                    <pip>
geopy                     1.11.0                    <pip>
gevent                    1.1.2                     <pip>
google-api-python-client  1.6.2                     <pip>
Google-Search-API         1.1.14                    <pip>
greenlet                  0.4.10                   py34_0
grequests                 0.2.0                     <pip>
h5py                      2.6.0               np111py34_2
hdf5                      1.8.15.1                 vc10_4  [vc10]
httplib2                  0.10.3                    <pip>
idna                      2.1                      py34_0
imagesize                 0.7.1                    py34_0
incremental               16.10.1                  py34_0
ipykernel                 4.5.0                    py34_0
ipython                   5.1.0                    py34_0
ipython-notebook          4.0.4                    py34_3
ipython-qtconsole         4.0.1                    py34_4
ipython_genutils          0.1.0                    py34_0
itsdangerous              0.24                     py34_0
jdcal                     1.3                      py34_0
jedi                      0.9.0                    py34_1
jinja2                    2.8                      py34_1
jpeg                      8d                       vc10_2  [vc10]
jsonschema                2.5.1                    py34_0
jupyter_client            4.4.0                    py34_0
jupyter_core              4.2.0                    py34_0
keggrest                  0.1.1                     <pip>
langdetect                1.0.7                     <pip>
Lasagne                   0.1                       <pip>
LatLon                    1.0.2                     <pip>
launcher                  1.0.0                         4
lda                       1.0.5                     <pip>
libChEBIpy                1.0.6                     <pip>
libpng                    1.6.22                   vc10_0  [vc10]
libpython                 3.4.3                     <pip>
libpython                 2.0                      py34_0
libtiff                   4.0.6                    vc10_2  [vc10]
llvmlite                  0.14.0                   py34_0
lsalib                    0.10.3                    <pip>
lxml                      3.6.4                    py34_0
m2w64-binutils            2.25.1                        4
m2w64-bzip2               1.0.6                         5
m2w64-crt-git             5.0.0.4636.2595836               1
m2w64-gcc                 5.3.0                         5
m2w64-gcc-ada             5.3.0                         5
m2w64-gcc-fortran         5.3.0                         5
m2w64-gcc-libgfortran     5.3.0                         5
m2w64-gcc-libs            5.3.0                         6
m2w64-gcc-objc            5.3.0                         5
m2w64-gmp                 6.1.0                         1
m2w64-headers-git         5.0.0.4636.c0ad18a               1
m2w64-isl                 0.16.1                        1
m2w64-libiconv            1.14                          5
m2w64-libmangle-git       5.0.0.4509.2e5a9a2               1
m2w64-libwinpthread-git   5.0.0.4634.697f757               1
m2w64-make                4.1.2351.a80a8b8               1
m2w64-mpc                 1.0.3                         2
m2w64-mpfr                3.1.4                         3
m2w64-pkg-config          0.29.1                        1
m2w64-toolchain           5.3.0                         6
m2w64-tools-git           5.0.0.4592.90b8472               1
m2w64-windows-default-manifest 6.4                           2
m2w64-winpthreads-git     5.0.0.4634.697f757               1
m2w64-zlib                1.2.8                         9
many-stop-words           0.2.2                     <pip>
markupsafe                0.23                     py34_2
matplotlib                1.5.1               np111py34_0
menuinst                  1.4.2                    py34_1
mingw                     4.7                           1
mistune                   0.7.3                    py34_0
mkl                       11.3.3                        1
mkl-service               1.1.2                    py34_2
mock                      2.0.0                    py34_0
mpmath                    0.19                     py34_1
msys2-conda-epoch         20160418                      0
multidict                 3.1.3                     <pip>
multipledispatch          0.4.9                    py34_0
mysqlclient               1.3.7                     <pip>
nbconvert                 4.2.0                    py34_0
nbformat                  4.1.0                    py34_0
networkx                  1.11                     py34_0
nltk                      3.2.1                    py34_0
node-webkit               0.10.1                        0
nose                      1.3.7                    py34_1
notebook                  4.2.3                    py34_0
numba                     0.29.0              np111py34_0
numexpr                   2.6.1               np111py34_1
numpy                     1.12.0rc1+mkl             <pip>
numpy                     1.11.2                   py34_0
oauth2client              4.0.0                     <pip>
oauthlib                  2.0.2                     <pip>
odo                       0.5.0                    py34_1
openpyxl                  2.4.0                    py34_0
openssl                   1.0.2j                   vc10_0  [vc10]
pandas                    0.19.0              np111py34_0
parsel                    1.1.0                    py34_0
path.py                   8.2.1                    py34_0
patsy                     0.4.1                    py34_0
pbr                       1.10.0                   py34_0
pdfminer.six              20160614                  <pip>
pep8                      1.7.0                    py34_0
pickleshare               0.7.4                    py34_0
pillow                    3.4.2                    py34_0
pip                       8.1.2                     <pip>
pip                       8.1.2                    py34_0
pip                       9.0.0                     <pip>
pkginfo                   1.3.2                    py34_0
ply                       3.9                      py34_0
prompt_toolkit            1.0.8                    py34_0
psutil                    4.4.2                    py34_0
psycopg2                  2.6.2                     <pip>
PubChemPy                 1.0.4                     <pip>
pubmed-lookup             0.2.1                     <pip>
py                        1.4.31                   py34_0
pyasn1                    0.2.3                     <pip>
pyasn1                    0.1.9                    py34_0
pyasn1-modules            0.0.8                    py34_0
pycosat                   0.6.1                    py34_1
pycparser                 2.16                     py34_0
pycrypto                  2.6.1                    py34_4
pydispatcher              2.0.5                    py34_0
pydpi                     1.0                       <pip>
pyflakes                  1.3.0                    py34_0
pygments                  2.1.3                    py34_0
pygoogle                  0.6                       <pip>
pygoogle-simple           0.2.3                     <pip>
pyopenssl                 16.2.0                   py34_0
pyparsing                 2.1.4                    py34_0
pyproj                    1.9.5.1                   <pip>
pyqt                      4.11.4                   py34_7
pyreadline                2.1                      py34_0
pytables                  3.2.2               np111py34_4
pytest                    3.0.3                    py34_0
python                    3.4.5                         0
python-btk                0.3.0                     <pip>
python-dateutil           2.5.3                    py34_0
python-instagram          1.3.2                     <pip>
python-twitter            3.2.1                     <pip>
pytz                      2016.7                   py34_0
pywin32                   220                      py34_1
pyyaml                    3.12                     py34_0
pyzmq                     16.0.0                   py34_0
qt                        4.8.7                    vc10_9  [vc10]
qtconsole                 4.2.1                    py34_0
queuelib                  1.4.2                    py34_0
requests                  2.5.3                     <pip>
requests                  2.13.0                   py34_0
requests-cache            0.4.13                    <pip>
requests-oauthlib         0.8.0                     <pip>
rope                      0.9.4                    py34_1
rsa                       3.4.2                     <pip>
ruamel_yaml               0.11.14                  py34_0
runipy                    0.1.3                    py34_0
scikit-image              0.12.3              np111py34_1
scikit-learn              0.18.1              np111py34_0
scikit-learn              0.17.1                    <pip>
scikit-neuralnetwork      0.7                       <pip>
scipy                     0.18.1              np111py34_0
scrapy                    1.1.1                    py34_0
selenium                  2.53.6                    <pip>
service_identity          16.0.0                   py34_0
setuptools                27.2.0                   py34_1
simplegeneric             0.8.1                    py34_1
simplejson                3.10.0                    <pip>
sip                       4.18                     py34_0
six                       1.10.0                   py34_0
sklearn                   0.0                       <pip>
snowballstemmer           1.2.1                    py34_0
sockjs-tornado            1.0.3                    py34_0
sphinx                    1.4.8                    py34_0
sphinx_rtd_theme          0.1.9                    py34_0
spyder                    2.3.8                    py34_1
spyder-app                2.3.8                    py34_0
sqlalchemy                1.1.3                    py34_0
statsmodels               0.6.1               np111py34_1
stop-words                2015.2.23.1               <pip>
sympy                     1.0                      py34_0
textblob                  0.13.0                    <pip>
theano                    0.8.2                    py34_0
Theano                    0.9.0.dev4                <pip>
tk                        8.5.18                   vc10_0  [vc10]
toolz                     0.8.0                    py34_0
tornado                   4.4.2                    py34_0
traitlets                 4.3.1                    py34_0
tweepy                    3.5.0                     <pip>
twisted                   16.6.0                   py34_0
ujson                     1.35                     py34_0
Unidecode                 0.04.21                   <pip>
uritemplate               3.0.0                     <pip>
urllib3                   1.22                      <pip>
vcrpy                     1.11.1                    <pip>
vs2010_runtime            10.00.40219.1                 2
w3lib                     1.16.0                   py34_0
wcwidth                   0.1.7                    py34_0
werkzeug                  0.11.11                  py34_0
wheel                     0.29.0                   py34_0
wikia                     1.4.3                     <pip>
wikipedia                 1.4.0                     <pip>
win_unicode_console       0.5                      py34_0
wrapt                     1.10.10                   <pip>
xlrd                      1.0.0                    py34_0
xlsxwriter                0.9.3                    py34_0
xlwings                   0.10.0                   py34_0
xlwt                      1.1.2                    py34_0
xmltodict                 0.11.0                    <pip>
yarl                      0.12.0                    <pip>
zlib                      1.2.8                    vc10_3  [vc10]
zope                      1.0                      py34_0
zope.interface            4.3.3                    py34_0
mnowotka commented 7 years ago

OK, first try:

pip install -U chembl_webresource_client

As I just pushed a new change, solving a bug in Python 3 descibed here: https://github.com/chembl/chembl_webresource_client/issues/22.

If this won't solve the problem, can you please use Conda to create a clean environment, using the following commands:

conda create -q -n client_3 python=3.6
source activate client_3
pip install chembl_webresource_client

This will create an empty conda environment with Python 3.6, switch to this environment and install the client there.

If this won't help please let me know as this may indicte some Windows-specific problem that I'd like to investigate.

Superraptor commented 7 years ago

Unfortunately, the first solution did not work, resulting in the same stack.

The second solution also hit the same problem:

  File "C:\Users\User Name\Anaconda3\envs\client_3\lib\site-packages\chembl_webresource_client\query_set.py", line 177, in get
    return self.query.get(*args, **kwargs)
  File "C:\Users\User Name\Anaconda3\envs\client_3\lib\site-packages\chembl_webresource_client\url_query.py", line 267, in get
    return self._get_by_ids(args[0])
  File "C:\Users\User Name\Anaconda3\envs\client_3\lib\site-packages\chembl_webresource_client\url_query.py", line 292, in _get_by_ids
    headers = {'Accept': mimetypes.types_map['.'+self.frmt]}
KeyError: '.json'
(client_3)

It's very possible that this is a Windows-specific problem.

mnowotka commented 7 years ago

OK, I think I fixed the bug. Can you please update the client:

 pip install -U chembl_webresource_client

verify if you have the latest version, which should be 0.9.18 and let me know if it works?

Superraptor commented 7 years ago

Works like a charm now! Thanks so much!